Strip out Excel timestamp

G

Guest

I have imported some data from an XL file into my Access db. One field is a
date field that also contains a timestamp along with the date. I would like
to strip out the timestamp just leaving the date as dd/mm/yyyy. Is there an
easy way to do this is Access or do I need to make the changes in the XL data
before importing into Access?

Thanks
Ian.
 
G

Guest

Do an update on the field like --
Int([YourFieldName])

Time is stored as a decimal fraction of the date. The integer of datetime
data is the date only.
 
D

Douglas J. Steele

While Int will work for most dates, you can't use it if the dates are prior
to 30 Dec, 1899, as they'll be negative numbers.

DateValue([YourFieldName]) is safer.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


KARL DEWEY said:
Do an update on the field like --
Int([YourFieldName])

Time is stored as a decimal fraction of the date. The integer of datetime
data is the date only.

Ian said:
I have imported some data from an XL file into my Access db. One field is
a
date field that also contains a timestamp along with the date. I would
like
to strip out the timestamp just leaving the date as dd/mm/yyyy. Is there
an
easy way to do this is Access or do I need to make the changes in the XL
data
before importing into Access?

Thanks
Ian.
 
J

Jeff Boyce

Why?

Are you trying to only see the date portion? If so, you can format the
display, and keep the time data -- you don't have to toss it.

Regards

Jeff Boyce
<Office/Access MVP>
 
G

Guest

Thanks for all the replies, its really helped. To answer the "Why" question,
I'm running queries comparing Date in already constructed tables with the
DateTime field in the new table and the time component is giving me spurrious
results in the query result. Second the Time component isn't actually
required, although if you know of a way to cleave the Time and write it to a
new field I could "Have my cake and eat it".

Thanks again
Ian.
 
D

Douglas J. Steele

Don't do it!

Don't separate Date and Time into two separate fields: you've got a
timestamp, and it should be a single field.

If you don't want the time, don't add it. If you want the time, use
DateValue (or TimeValue) to extract only that component of the timestamp in
which you're currently interested.
 
G

Guest

Thanks Douglas,

Noted and understood, it's only the date I need and I'll use your suggestion.

Cheers,
Ian.
 
B

Brian Wilson

Douglas J. Steele said:
While Int will work for most dates, you can't use it if the dates are
prior to 30 Dec, 1899, as they'll be negative numbers.

DateValue([YourFieldName]) is safer.


I see... so this wouldn't work for the pork pie sell-by dates from our local
pub.
 

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

Similar Threads

timestamp handle 5
DB2 timestamp format 2
>> sql timestamp 4
Delete Timestamp 2
Date Timestamp 1
Date format exporting in 2000 1
Seperating a Timestamp 4
Timestamp as Name of File 0

Top