Using Access 7.0 DateTime in SQL Query 
Author Message
 Using Access 7.0 DateTime in SQL Query

Hi,

Can anybody help me do an sql query on a table using the datetime format?

I have tried several methods but cannot get any to find the required
record.

An entry is time stamped using VB5.0 Now statement which returns a double.

I can create the record and if I view it with Access 7.0 or VisData the
field correctly shows the date time of the record.

However, when I try to search for the record It never finds it. The SQl
query looks like...

sql$="select * from CallHistory where datetime="+trim$( str$( CallStart# ))

I tried Converting the date format to the same as displayed by
Access/VisData but the SQL didn't like the space in between the date /
time, ie...

sql$="select * from CallHistory where datetime="+format$( CallStart#
,"dd/mm/yy hh:mm:ss")

Putting the date in quotes the reported a type mis-match.

I also tried changing the field type to a double and although the value was
exactly the same in the table and the query it still didn't find it.

Please help as I'm rapidly running out of hair!!!!

Cesare

p.s. Thanks to anybody who replies.



Fri, 10 Mar 2000 03:00:00 GMT  
 Using Access 7.0 DateTime in SQL Query

Quote:

> Can anybody help me do an sql query on a table using the datetime format?

> sql$="select * from CallHistory where datetime="+trim$( str$( CallStart# ))

> sql$="select * from CallHistory where datetime="+format$( CallStart#
> ,"dd/mm/yy hh:mm:ss")

Hi Cesare,

You have to insert # before and after your date, and also it must be in
yy/mm/dd format - like this:

sql$="select * from CallHistory where datetime=#" & format$( CallStart#
,"yy/mm/dd hh:mm:ss)" & "#"

Cheers,

Dan



Fri, 10 Mar 2000 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. SQL datetime query on Access DB

2. Datetime and SQL-Server 7.0

3. Executing Access 7.0 action queries from VB4 using RDO

4. Executing Access 7.0 action queries from VB4 using RDO

5. VB4.0 (32-bit) access 7.0 empty datetime field

6. USing ASP migrating from SQL 6.5 to SQL 7.0

7. Converting a VB.NET DateTime to SQL DateTime

8. SQL-syntax SQL-Server 7.0 / Access 97

9. CR 7.0 SQL Query Designer

10. using intergrated access SQL-query in visual basic

11. HELP!!! Using access to query SQL

12. Accessing Regional Settings and using in SQL Queries

 

 
Powered by phpBB® Forum Software