Board index » delphi » date filtering a table component

date filtering a table component

I am a Delphi novice, trying to filter records for a quick report.

- I have a table component
- I am trying to set the filter property
- I started by hard coding the property as follows
  ([date] >= 04-20-98)
where date is my field name, but I get an invalid date prompt, also tried
  ([date] >= 20-04-98) as I would with my dates set to Australian format but
no luck.
- I'm using Delphi 2.0 desktop / std

Can anyone help?

Thanks

 

Re:date filtering a table component


I am a Delphi novice, trying to filter records for a quick report.
- I have a table component
- I am trying to set the filter property
- I started by hard coding the property as follows
  ([date] >= 04-20-98)
where date is my field name, but I get an invalid date prompt, also tried
  ([date] >= 20-04-98) as I would with my dates set to Australian format but
no luck.
- I'm using Delphi 2.0 desktop / std
Can anyone help?
Thanks

Re:date filtering a table component


Quote
"dick Walker" <di...@pcug.org.au> wrote:
>>- I have a table component
>>- I am trying to set the filter property
>>- I started by hard coding the property as follows  ([date] >= 04-20-98)
>>  where date is my field name, but I get an invalid date prompt, also tried
>>  ([date] >= 20-04-98) as I would with my dates set to Australian format
>>  but no luck.
>>- I'm using Delphi 2.0 desktop / std

There are a couple of things that need to be done.  First, you have to
use compatible types for the evaluation. Second, you have to make sure
the date format and date separator are what your program expects.  I
_always_ set ShortDateFormat and DateSeparator in my programs instead
of relying on the windows settings.

So, for example, if your date field is named Date1, you would use the
following when hard-coding if your property

ShortDateFormat := 'DD-MM-YY';
DateSeparator := '-';
if Table1Date1.AsDateTime >=  StrToDateTime('20-04-98') then ...

Hope that helps...

Christopher di Armani
diarm...@yahoo.com

Other Threads