How would I fetch all results for a certain date like you do with the time?Quote:
Dates and times in Access *MUST* be surrounded by #...# instead of '...'.
... WHERE upload_time = #5:10 AM#
if you omit the AM/PM, then 24-hour clock is assumed. So you could do
... WHERE upload_time = #7:32 PM#
... WHERE upload_time = #19:32#
One thing to DEFINITELY watch out for: DATES in Access *MUST* be in either USA format (#mm/dd/yyyy#) or ISO format (#yyyy/mm/dd#). They can *NOT* be in UK format (#dd/mm/yyyy#) unfortunately.
I strongly recommend using ISO format. So you can use a VBS function to help do that:
Oh...and you can use DATEVALUE() and TIMEVALUE() In Access queries, as well.Code:
Function ISODate( dt )
iso = year(dt) & "/" & month(dt) & "/" & day(dt)
If TimeValue(dt) <> 0 Then iso = iso & " " & TimeValue(dt)
ISODate = "#" & iso & "#"
' and then use it in a query thus:
sql = "SELECT * FROM tbl WHERE dtfield = " & ISODate(someVBScriptDateTime)
For example, if you wanted to find all records where upload_time is between 5PM and 6PM, *regardless* of what DATE they were uploaded:
Oh...and pleas don't tell me you have both upload_date and upload_time. No reason at all to do that. Just use upload_time (or upload_date_time, perhaps) to hold a DATETIME value which is both.Code:
sql = "SELECT * FROM images WHERE TIMEVALUE(upload_time) BETWEEN #5:00PM# AND #6:00PM#"