Help with querying data based on time 
Author Message
 Help with querying data based on time

Hi,

Wonderin' if someone could help, I'm trying to query some data using SQL based on time. Here is a sample of my code.

dim arrivaltime as string
dim departtime as string

SELECT info FROM supplier WHERE arrivaltime = 'arrivaltime' AND departtime = 'departtime'

For some reason I am unable retrieving any data from this query.  When I do a msgbox for the arrival and departime
they appear to match the data in the table.

arrivaltime = "1:00:00 PM"    
departtime = "2:00:00 PM"



Sat, 15 Jan 2005 06:53:00 GMT  
 Help with querying data based on time
Thate depends how your table "supplier"
is defined. It the "arrivaltime" and "departtime"
fields are of type string (which I think is bad practice)
then you have to make sure you get the format exactly
right, i.e. 1:00:00 PM <> 01:00:00 PM <> 13:00:00

The better way would be to define thos columns as ADO
Date columns, in which case your query has to look something like this:

Dim arrivaltime as Date
Dim departtime as Date

strSQL = "SELECT info FROM supplier WHERE arrivaltime = #" & arrivaltime &
"# AND departtime = #" & departtime & "#"

HTH,
Mike


Quote:
> Hi,

> Wonderin' if someone could help, I'm trying to query some data using SQL

based on time. Here is a sample of my code.
Quote:

> dim arrivaltime as string
> dim departtime as string

> SELECT info FROM supplier WHERE arrivaltime = 'arrivaltime' AND departtime
= 'departtime'

> For some reason I am unable retrieving any data from this query.  When I

do a msgbox for the arrival and departime
Quote:
> they appear to match the data in the table.

> arrivaltime = "1:00:00 PM"
> departtime = "2:00:00 PM"



Sun, 16 Jan 2005 21:54:11 GMT  
 Help with querying data based on time
Thanks for the reply,

I just  figured out what was happening. For some reason my SQL database automataically insert a date of 1899-12-30 into
my data\time column. I  don't know why this happens, if someone could explain, thanks.



Mon, 17 Jan 2005 06:27:48 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. How to Query on Data Enviroment based data form

2. Help - Simply Getting Data from Extrenal Data Files (not from Access Data Base)

3. Remote Data Base Connection and Query

4. querying Data bases

5. Parameter queries, list boxes and data bases oh my

6. Problem accessing record from SQL Data base Date/Time Field

7. Basing query on another query

8. base a query on another query?

9. Query based form, Help please.

10. Help with linking forms - query based on master form

11. Web based form feeding a vb data base

12. Help with time based logging

 

 
Powered by phpBB® Forum Software