Board index » delphi » Query DateTime Field

Query DateTime Field

How do I use local SQL to query a date time field?

The statement:

select * from myTable tbl
where tbl.MyDateTime > ("5/6/00,08:40:00 PM")

returns records with the correct date, but the time seems to be ignored.
Why?

 

Re:Query DateTime Field


Quote
Rick wrote in message <3914fe5e@dnews>...
>How do I use local SQL to query a date time field?

>The statement:

>select * from myTable tbl
>where tbl.MyDateTime > ("5/6/00,08:40:00 PM")

Try using parameters instead, then you don't have to worry about the exact
format required for a date string.

select * from myTable tbl
where tbl.MyDateTime > :mydatetime

    Query1.Close;
    Query1.Params[0].AsDateTime :=
        Now - 7; // exact time 1 week ago
    Query1.Open;

--
Wayne Niddery - WinWright Consulting
RADBooks - http://members.home.net/wniddery/
You have a Right to Free Speech, but not the right to make me listen, nor to
use my property as a soapbox.

Other Threads