Happy Day.

As I continually preach, the safest way to deal with dates under any SQL
engine is via parameters.

MyQuery.SQL.Text := 'SELECT * FROM MeasuredData WHERE DateTimeAdded =
:DATEPARAM';
MyQuery.ParamByName('DATEPARAM').AsDateTime := SomeTDateTimeValue;

By doing this you'll never need to think about what date syntax your
database engine is expecting, which is handy if you ever expect to switch
database engines.  You also save yourself a lot of string handling.

Cheers.
                        BJ...

-----Original Message-----
From: Scott Cree <[EMAIL PROTECTED]>
To: Multiple recipients of list database <[EMAIL PROTECTED]>
Date: Friday, 19 May 2000 11:22
Subject: RE: [DUG-DB]: Dates in SQL/Access


>You might need to use # around the date as well as in:
>
>  SELECT *
>  FROM MeasuredData
>  WHERE DateTimeAdded > #07/03/1999#
>
>
>
>-----Original Message-----
>From: Derricutt, Mark [mailto:[EMAIL PROTECTED]]
>Sent: Friday, 19 May 2000 11:35
>To: Multiple recipients of list database
>Subject: RE: [DUG-DB]: Dates in SQL/Access
>
>
>> It should be mm/dd/yyyy if you're doing any sql in Access.
>
>Thats what I thought, however the query:
>
>  SELECT *
>  FROM MeasuredData
>  WHERE DateTimeAdded > '07/03/1999'
>
>generates a "Datatype Mismatch in Criteria Expression" error.
>---------------------------------------------------------------------------
>  New Zealand Delphi Users group - Database List - [EMAIL PROTECTED]
>                  Website: http://www.delphi.org.nz
>---------------------------------------------------------------------------
>  New Zealand Delphi Users group - Database List - [EMAIL PROTECTED]
>                  Website: http://www.delphi.org.nz
>
>


---------------------------------------------------------------------------
  New Zealand Delphi Users group - Database List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz

Reply via email to