That depends on your database.
Using Interbase I would not use the filter option. I would use a TQuery as
the Client dataset and use a parameter.
e.g.
Query1.SQL.Add('SELECT * FROM TABLENAME WHERE TARGETDATE = :TARGETDATE');
Query1.Params[0].asDateTime := TargetDateVariable;
Where TargetDateVariable is of type TDate;
Otherwise you run into all sorts of trouble where some databases use the
ShortDateFormat and others e.g. Interbase 6 which completely ignores your
ShortDateFormat and just goes for mm/dd/yyyy no matter what you do.
Or you can be tricky and set the ShortDateFormat directly before you run the
filter and this _normally_ works. (Although not with Interbase 6 in my
experience...)
Steve
-----Original Message-----
From: Stephen Bertram [mailto:[EMAIL PROTECTED]]
Sent: Thursday, 5 July 2001 12:29
To: Multiple recipients of list delphi
Subject: [DUG]: Using Dates in ClientDataset Filters
What is a method of specifying a date in a filter string for a ClientDataset
that is independent of the local ShortDateFormat ?
Obviously 'DateField = ''' + DateToStr(TargetDate) + '''' does not work.
Nor does 'DateField = ' + FloatToStr(TargetDate).
Is there a date format that can be used safely?
eg 'DateField = ''' + FormatDateTime('YYYYMMDD', TargetDate) + ''''
TIA
Stephen
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED]
with body of "unsubscribe delphi"
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED]
with body of "unsubscribe delphi"