Never trust the date format of your current SQL engine. If you switch DB
engines or your database changes its date format, you'll be left with a lot
of hard coded date formatting. The best way to do it is to let the BDE
format it for you by using parameters:
SELECT * FROM MY_TABLE WHERE MY_DATE_FIELD = :DATE_PARAM;
Then you can set the parameter as TDateTime or as String in Delphi and you
don't have to think about what the database engine is expecting. You'll
also be sure to be Y2K compliant (assuming that your database engine is).
It's worth noting that the AsString method of TParam and TField are
different: one of them expects a database-favourite-format and the other
expects a what-the-system-settings-are formatting. I forget which one uses
which.
The safest way to go is use parameters for all interaction with the database
and to always interact with TParams and TFields as TDateTime until the last
moment that you need to convert to a string for display.
Cheers.
BJ...
-----Original Message-----
From: Mark Derricutt <[EMAIL PROTECTED]>
To: Multiple recipients of list delphi <[EMAIL PROTECTED]>
Date: Thursday, 8 July 1999 11:15
Subject: Re: [DUG]: SQL Dates/Times
--On Thursday, July 08, 1999, 11:11 AM +1200 Mark Derricutt
<[EMAIL PROTECTED]> wrote:
> Whats the correct formatting for a date/time combination in SQL?
"1-Jan-1998 12:30:00 AM" works :-) w00p.
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz