Board index » delphi » Problem querying Access DATETIME fields

Problem querying Access DATETIME fields

Hi,

  I have a datetime field in a table: '01/06/2001 15:59:35'

If I run the query

'select * from Table where DateField >= :dDate'
Parameters.ParamByName('dDate').AsValue := now; (lets say 01/06/2001
16:00:26'),

I get an empty dataset back. I thought it might be to do with the
parameters, so now im trying to convert to a string to be sure.

How do I specify the timestamp when querying the datetime ?

select * from table where DateField >= '01/06/2001 16:00:26' does not work.

Please help

thanks

 

Re:Problem querying Access DATETIME fields


Quote
>How do I specify the timestamp when querying the datetime ?

>select * from table where DateField >= '01/06/2001 16:00:26' does not work.

Access likes date values delimited with # characters
--
Brian Bushay (TeamB)
Bbus...@NMPLS.com

Re:Problem querying Access DATETIME fields


Thanks for the tip!
Quote
>Access likes date values delimited with # characters
>Brian Bushay (TeamB)

Re:Problem querying Access DATETIME fields


Hi,

sadly this does not work

select * from Vehicles where V_DateModified >= "2001-06-01#18:29:56"

Invalid Data type

Am i doing something wrong ?
Thanks

BBus...@Nmpls.com (Brian Bushay TeamB) wrote in
<j1oghtolnp8vc2dseotcodfh39pvul2...@4ax.com>:

Quote

>>How do I specify the timestamp when querying the datetime ?

>>select * from table where DateField >= '01/06/2001 16:00:26' does not
>>work.

>Access likes date values delimited with # characters
>--
>Brian Bushay (TeamB)
>Bbus...@NMPLS.com

Re:Problem querying Access DATETIME fields


I got it working.

"select * from Vehicles where V_DateModified > #01/06/2001 18:29:56#"

Re:Problem querying Access DATETIME fields


Quote
>select * from Vehicles where V_DateModified >= "2001-06-01#18:29:56"

>Invalid Data type

>Am i doing something wrong ?

Use mm/dd/yyyy date format and delimit the full datetime value with # characters

select * from Vehicles where V_DateModified >= #01/06/200118:29:56#

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

Other Threads