Extract just the date from Date Time

N

Neal

I have a date time filed that time stamps records. Now I want to use just
the date, but if I format it to date only it looks good, but later when I
use it in a query it has the times so I don't get the unique dates.
What criteria do I use to get just the date? I tried INT([timestamp]) but
it didn't like it.

Thanks, Neal.
 
N

Neal

Thanks again!

This works in the Field: line of a query, but doesn't seem to work on the
Criteria line. Does what I need though! (-:


Ofer said:
Try

DateValue([DateTimeField)

--
\\// Live Long and Prosper \\//
BS"D


Neal said:
I have a date time filed that time stamps records. Now I want to use
just
the date, but if I format it to date only it looks good, but later when I
use it in a query it has the times so I don't get the unique dates.
What criteria do I use to get just the date? I tried INT([timestamp])
but
it didn't like it.

Thanks, Neal.
 
O

OfficeDev18 via AccessMonster.com

It's unfortunate, Neal, but many times timestamping is done in text (string)
fields instead of real date fields, If that's the case, use the InStr()
function to isolate the date portion of the timestamp field, and use the
CDate() function to access the substring as a date.

If, for example, the timestamp is "The Date: 02/20/2006; The Time: 2:56:30
PM", do this:

Dim SStrg As String

SStrg = InStr(TimeStampField,11,10)
CDate(SStrg), then, will give you the proper date format.

By the way, if you're using this in a Access' query design interface, of
course, just use

DateOnly: CDate(InStr(TimeStampField,11,10))

However, I'm not convinced that was the problem. Was there a specific error
message that came up when you used Int()? Did you try CDate(Int
(TimeStampField))? That would turn your 5-digit number into a real date - if
it works at all.

Sam
I have a date time filed that time stamps records. Now I want to use just
the date, but if I format it to date only it looks good, but later when I
use it in a query it has the times so I don't get the unique dates.
What criteria do I use to get just the date? I tried INT([timestamp]) but
it didn't like it.

Thanks, Neal.
 
G

Guest

Can you post your SQL?

--
\\// Live Long and Prosper \\//
BS"D


Neal said:
Thanks again!

This works in the Field: line of a query, but doesn't seem to work on the
Criteria line. Does what I need though! (-:


Ofer said:
Try

DateValue([DateTimeField)

--
\\// Live Long and Prosper \\//
BS"D


Neal said:
I have a date time filed that time stamps records. Now I want to use
just
the date, but if I format it to date only it looks good, but later when I
use it in a query it has the times so I don't get the unique dates.
What criteria do I use to get just the date? I tried INT([timestamp])
but
it didn't like it.

Thanks, Neal.
 

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