Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 3 of 3 total
Thread need help formatting a where clause
Thu, Mar 15 2007 4:56 PMPermanent Link

Jerry Blumenthal
I need to do a search for a record using a WHERE clause, looking for a
match with a date time.

The date and time = 12/29/2005 10:00:00 AM

How do I format a where clause to look for that?  Using
DateToDBIsamString gives me "12/29/2005".

Jerry
Thu, Mar 15 2007 5:37 PMPermanent Link

Steve Forbes

Team Elevate Team Elevate

Hi Jerry,

If the date/time parameter is going to change, I would strongly suggest
using an SQL parameter which will remove your problems entirely e.g.

SQL.Text := 'SELECT * FROM MyTable WHERE DateTimeColumn = TongueTimeStamp';
ParamByName('pmTimeStamp').AsDateTime := DateTimeVariable
Active := True;

otherwise, IIRC the date/time value should be formatted as follows in the
SQL statement:

WHERE DateTimeColumn = '2005-12-29 10:00:00.00'

HTH
--
Best regards

Steve

"Jerry Blumenthal" <jerry@blumenthalsoftware.com> wrote in message
news:F07A777D-BB5C-4C9D-8C24-9FBFE6052949@news.elevatesoft.com...
>I need to do a search for a record using a WHERE clause, looking for a
>match with a date time.
>
> The date and time = 12/29/2005 10:00:00 AM
>
> How do I format a where clause to look for that?  Using DateToDBIsamString
> gives me "12/29/2005".
>
> Jerry

Thu, Mar 22 2007 5:25 PMPermanent Link

"Adam H."
Hi Jerry,

Just to add to what Steve mentioned, you may want to consider using 2 where
clauses, and doing an 'inbetween'.

Maybe something like

WHERE (DateTimeColumn > '2005-12-29 09:59:59')
and (DateTimeColumn < '2005-12-29 10:00:01').

IIRC, the DateTime formats are stored as a floating value, which means
(calculating to the millisecond) you may not get an exact match to the
millisecond for a recorded record. (If that makes sense). Normally, to
combat this, I use greater than and less than, and seperate by a second as
described above.

Cheers

Adam.

Image