HOW TO OBTAIN ONLY THE DATE OF A timestamp FIELD

R

R Walle

I have a datalog loaading data to an Access database and each time the data
is logged it have a timestamp and its fine but now Im trying to set up a
query that shows all the data logged during a time period between days so I
need only dates, is there a function that I can use to run my query only with
the "date" part of the timestamp
 
J

Jerry Whittle

TheDate: CDate(CLng([TheDateTimeField]))

CLng convert the date to an integer which gets rid of the time.

CDate makes it look like a date again.
 
M

Marshall Barton

R Walle said:
I have a datalog loaading data to an Access database and each time the data
is logged it have a timestamp and its fine but now Im trying to set up a
query that shows all the data logged during a time period between days so I
need only dates, is there a function that I can use to run my query only with
the "date" part of the timestamp


The DateValue() function
 
J

John W. Vinson

On Fri, 23 Oct 2009 13:19:02 -0700, R Walle <R
I have a datalog loaading data to an Access database and each time the data
is logged it have a timestamp and its fine but now Im trying to set up a
query that shows all the data logged during a time period between days so I
need only dates, is there a function that I can use to run my query only with
the "date" part of the timestamp

If the timestamp is in fact in an Access Date/Time field (rather than, say, a
SQL/Server Timestamp field, which isn't really a date at all), you can use a
query criterion like
= [Enter start date:] AND < DateAdd("d", 1, [Enter end date:])

This will pick up all records between the start of the first date and before
the end of the second, *and* it will make use of any Indexes on your timestamp
field, improving performance.

If you prefer, use a calculated field

JustTheDate: Datevalue([timestamp])

to return only the date portion. This will query much more slowly since Access
must call a function on every row, and do a full table scan in the process.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top