Select Date but not Time

kikeman

Registered User.
Local time
Yesterday, 18:48
Joined
Nov 20, 2009
Messages
13
Hi,

I have a table with "Orders", these orders were inserted with certain
Date/Time column called "InstTime" (I really need to store also the time):

"Orders" "InstTime"
123678 12/1/2009 4:10:09 PM

I would like to select the Orders according to certain Date (12/1/2009), but
ignoring the time (4:10:09 PM). What would be SELECT command for this
scenario.

I am using OleDB from C#.

Thanks.
 
Date is stored as a number of days. Time is the part of a day.

Try this:
[somedate] is a criteria, a field in the query or a control on a form.

WHERE [InstTime] BETWEEN [somedate] AND [somedate]+1

This should give you all the InstTime from 0:00 on the day to 0:00 on the next day (effectively midnight to midnight). If records on the stroke of midnight are possible then use:
[somedate] + 0.99999
 
Hi -

The DateValue() function returns just the date portion of date/time
fields. Examples:

Code:
tfield = now()
? dtfield
12/2/2009 7:16:03 AM 
 
dfield = datevalue(dtfield)
? dfield
12/2/2009 

To see how they're stored by Access:
? cdbl(dtfield)
 40149.3028125 

? cdbl(dfield)
 40149

HTH - Bob
 

Users who are viewing this thread

Back
Top Bottom