Solved

Date

Posted on 2001-07-02
9
330 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Thread safe  opinion 7 126
Delphi Form ownership 4 73
TServerSocket - file via sendbuf or Text via sendtext ? 1 44
How to convert memory stream to PDF file 6 22
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

861 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

24 Experts available now in Live!

Get 1:1 Help Now