Solved

Date

Posted on 2001-07-02
9
328 Views
Last Modified: 2011-09-20
I want to filter my tables DATE field to Date+7 but i want to filter not only date+7 i also want date+6 date+5 date+4 date+3 date+2 and date+1. My table connected to a datasource and a DBGrid to a datasource. I want to show all filtered records on DBGrid. If i try:

Table1.Filter := 'DATE = ''' + datetostr(date+7) + '''';
it only Filter records that has (if today is 01.01.1999) 07.01.1999 on DATE field. But as i said before i want to filter dates between today and seven days later..
0
Comment
Question by:systemop
  • 4
  • 3
  • 2
9 Comments
 
LVL 13

Expert Comment

by:Epsylon
ID: 6243999
Try this:

Table1.Filter := 'DATE between''' + datetostr(date) + ' and ' + datetostr(date+7) + '''';
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 6244024
Maybe it's necessary to use date+8 instead of date+7:

Table1.Filter := 'DATE between''' + datetostr(date) + ' and ' + datetostr(date+8) + '''';
0
 

Author Comment

by:systemop
ID: 6244074
Epsylon it gives this error :

Filter expression incorrectly terminated..
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 6244143
Table1.Filter := 'DATE between''' + datetostr(date) + ''' and ''' + datetostr(date+8) + '''';
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 9

Accepted Solution

by:
ITugay earned 50 total points
ID: 6244148
Hi systemop,

  Query1.Filter :=  'PJ_BEG >= '''+DateToStr(Date)+''' AND PJ_BEG < '''+DateToStr(Date+7)+'''';
  Query1.Filtered := true;

----
Igor.
0
 

Author Comment

by:systemop
ID: 6244210
Epsylon it gives same error.

ITugay i use Table1 not Query how can i solve this with Table
0
 
LVL 9

Expert Comment

by:ITugay
ID: 6244225
The same way, Just change Query1 to Table1 :-)
------
Igor.
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 6244235
Another shot  :o)

Table1.Filter := 'DATE between ''' + datetostr(date) + ''' and ''' + datetostr(date+8) + '''';
0
 

Author Comment

by:systemop
ID: 6244259
Thank you ITugay it works..
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
This video discusses moving either the default database or any database to a new volume.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now