Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How would you parse a data string like this? 2

Status
Not open for further replies.

glthornton

Programmer
Oct 19, 2005
108
US
Hi everyone,

I'm using Access 2000 and I'm trying to parse a data string like "3/19/2003 10:36:00 AM" into it's separate parts. What I need is:

Month=3
Day=19
Year=2003
Time1=10
Time2=36

Does anyone have a suggestion as to how this can be done?

Thank you,

glthornton
 



Hi,

Use the Year(), Month(), Day(), Hour(), Minute(), Second() functions.

Skip,
[sub]
[glasses] [red][/red]
[tongue][/sub]
 


BTW, I assumed that this was NOT a string but a REAL DATE/TIME value.

If it is indeed a string, simply convert to a DATE/TIME Value...
Code:
s = "3/19/2003 10:36:00 AM"
d = DateValue(s) + TimeValue(s)
MyYear = Year(d)
MyHour = Hour(d)


Skip,
[sub]
[glasses] [red][/red]
[tongue][/sub]
 
You can also use the DatePart function

For example
Code:
 DatePart("h",[Date_Update]) AS Hours,  DatePart("n",[Date_Update]) AS Minutes
 
Thanks Skip and IT as they are both valid ways of extracting the data. Awesome suggestions!!
glthornton
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top