• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 372
  • Last Modified:

Date

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
systemop
Asked:
systemop
  • 4
  • 3
  • 2
1 Solution
 
EpsylonCommented:
Try this:

Table1.Filter := 'DATE between''' + datetostr(date) + ' and ' + datetostr(date+7) + '''';
0
 
EpsylonCommented:
Maybe it's necessary to use date+8 instead of date+7:

Table1.Filter := 'DATE between''' + datetostr(date) + ' and ' + datetostr(date+8) + '''';
0
 
systemopAuthor Commented:
Epsylon it gives this error :

Filter expression incorrectly terminated..
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
EpsylonCommented:
Table1.Filter := 'DATE between''' + datetostr(date) + ''' and ''' + datetostr(date+8) + '''';
0
 
ITugayCommented:
Hi systemop,

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

----
Igor.
0
 
systemopAuthor Commented:
Epsylon it gives same error.

ITugay i use Table1 not Query how can i solve this with Table
0
 
ITugayCommented:
The same way, Just change Query1 to Table1 :-)
------
Igor.
0
 
EpsylonCommented:
Another shot  :o)

Table1.Filter := 'DATE between ''' + datetostr(date) + ''' and ''' + datetostr(date+8) + '''';
0
 
systemopAuthor Commented:
Thank you ITugay it works..
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now