Board index » delphi » Help with Date Query String

Help with Date Query String

Brian:

Yes, the date must appear in the WHERE clause as a literal.

To test the validity of SQL, I usually use Database Desktop and try the
SQL there first.... then I build the string in code in my apps.

mIKE

 

Re:Help with Date Query String


Hi

Tearing my hair out on this one...

What I want to do is send a sql string to a TQuery that
will allow me to return records based on a comparison
of the current system date (Date) with a Date/Time field
in an Access Database.( Using DAO).

ie 'select * from stuff where mdb_date < date'

The sql string (being a string) will not accept the Date
unless I convert it (DateToStr)..........

dunno probably something simple

Any help would be appreciated

Brian Aitken

aitk...@wbinet.com
.

Re:Help with Date Query String


Quote
>ie 'select * from stuff where mdb_date < date'

>The sql string (being a string) will not accept the Date
>unless I convert it (DateToStr)..........

You can use a parameter

'select * from stuff where mdb_date <: date'
ParambyName(date).asDateTime := sysUtils.date;

--
Brian Bushay (TeamB)
Bbus...@NMPLS.com

Re:Help with Date Query String


I beleive you need to enclose the date string in hashes like
'#dd/mm/yyyy#'.

HTH

Ray Cramer
R...@Pol.ac.uk

Quote
Brian Aitken wrote:
> Hi

> Tearing my hair out on this one...

> What I want to do is send a sql string to a TQuery that
> will allow me to return records based on a comparison
> of the current system date (Date) with a Date/Time field
> in an Access Database.( Using DAO).

> ie 'select * from stuff where mdb_date < date'

> The sql string (being a string) will not accept the Date
> unless I convert it (DateToStr)..........

> dunno probably something simple

> Any help would be appreciated

> Brian Aitken

> aitk...@wbinet.com
> .

Re:Help with Date Query String


In article <36e646e9.21473454@floyd>, BBus...@Nmpls.com (Brian Bushay TeamB) wrote:

Quote

>>ie 'select * from stuff where mdb_date < date'

>>The sql string (being a string) will not accept the Date
>>unless I convert it (DateToStr)..........

>You can use a parameter

>'select * from stuff where mdb_date <: date'
>ParambyName(date).asDateTime := sysUtils.date;

Worked like a charm...

Thanks

Brian

Other Threads