Thanks Steve

I don't have a problem with SQL databases - I've sorted out dates there and
it also is controllable on a server.

My problem is on TClientDataset where the local user can put any format they
like in (eg mm-ddd-yy) and stuff up the data handling in the Dataset.Filter
property.

The Delphi help refers to a mythical GetDate (the current date) which does
not exist in TClientDataset or DB.  I could use this with an offset to
specify a date if it existed. 

Stephen


-----Original Message-----
From: Steve Aish [mailto:[EMAIL PROTECTED]]
Sent: Thursday, 5 July 2001 12:35 p.m.
To: Multiple recipients of list delphi
Subject: RE: [DUG]: Using Dates in ClientDataset Filters


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"
---------------------------------------------------------------------------
    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"

Reply via email to