parsing datetime field into month, day, year, time

C

CJ

Hi there,
I have a list of date and times in one field
called "datetime"

For example:
DATETIME
1/1/2000 12:17:00 AM
12/31/1999 7:40:00 PM
12/31/1999 10:20:00 PM
12/31/1999 9:20:00 PM
12/31/1999 9:20:00 PM
12/31/1999 8:30:00 PM
1/1/2000 12:50:00 AM

I understand how right, left, and mid syntax can extract
out certain characters from a string...but due to the
fact that the month and day can be either 1 digit or 2
digits, that won't work for me. I need to extract out
the month, day, year, and time into individual variables,
and also add a leading zero to the months and days that
are 9 or lower. I wondered if someone could help me with
this problem. I am not sure how to use a Module (if code
to paste into a module is provided for me) - and so if
there is a single line that I can paste into the "Field:"
field for each variable I need (day, month, year, time),
that would be excellent. Thank you in advance for your
help.
CJ
 
F

fredg

12/31/1999 7:40:00 PM

Let Access do the work.
This should work for the field if it is a Text datatype as well as a
Date/Time datatype.

MonthValue:Format([FieldName],"mm")
YearValue:Format(FieldName],"yyyy")
DayValue:Format([FieldName],"dd")
TimeValue:Format([FieldName],"hh:nn:ss")
 
C

CJ

Fred,
It worked like a charm. Thank you very much. I don't
understand how Access actually did it, but I am glad it
worked so well.

CJ
-----Original Message-----
12/31/1999 7:40:00 PM

Let Access do the work.
This should work for the field if it is a Text datatype as well as a
Date/Time datatype.

MonthValue:Format([FieldName],"mm")
YearValue:Format(FieldName],"yyyy")
DayValue:Format([FieldName],"dd")
TimeValue:Format([FieldName],"hh:nn:ss")

--
Fred
Please only reply to this newsgroup.
I do not reply to personal email.
.
 

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


Top