Filter with a date range

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
shsit
Posts: 21
Joined: Thu 05 Oct 2006 11:41

Filter with a date range

Post by shsit » Mon 16 May 2011 17:56

Hello,

consider the following table:

ID DateFrom DateTo
1 6.5.2011 6.5.2011
2 7.5.2011 9.5.2011


Using a TUniQuery with ADS Database (10.10), I want to set a filter over a data range.

This filter works:

Code: Select all

      UniQuery1.Filter := 'DateFrom >= '+ QuotedStr('06.05.2011') +
                               ' AND DateTo = '+ QuotedStr('08.05.2011') +
                               ' AND DateTo <= ' + QuotedStr('08.05.2011');
      UniQuery1.Filtered := True;

Any ideas why the filter isn't working?
Thank you very much!

AndreyZ

Post by AndreyZ » Tue 17 May 2011 05:40

Hello,

There are no such records in your table where DateFrom column value is bigger than 08.05.2011 . That's why with this filter you don't get any records. You can try using the following code:

Code: Select all

UniQuery1.Filter := 'DateFrom = ' + QuotedStr('06.05.2011');
UniQuery1.Filtered := True;
and

Code: Select all

UniQuery1.Filter := 'DateFrom = ' + QuotedStr('08.05.2011');
UniQuery1.Filtered := True;

shsit
Posts: 21
Joined: Thu 05 Oct 2006 11:41

Post by shsit » Tue 17 May 2011 06:17

Hi Andrey,
excuse me of course you are right. I guess the day yesterday was a little to long :oops:

AndreyZ

Post by AndreyZ » Tue 17 May 2011 06:27

Feel free to contact us if you have any further questions about UniDAC.

Post Reply