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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need to extract a 1 or 2 digit month from data field 1

Status
Not open for further replies.

kpal29

Technical User
Feb 8, 2003
147
DK
I have a month field. I also have a date field called eta.
The field is formatted as follows:
1/20/04
10/2/03
/ /

It can be a 1 or 2 digit month or just have the formatting.
I need to be able to extract the month number only, not the / if the month number is just one digit. I need to use this statement in an update query to update my month field.

How can I tell access to ignore the slash if the month is 1-9?
 
Left([fieldname], InStr(1, [fieldname], "/") - 1)

Will return any and all characters BEFORE the first slash....should meet your needs dead on.

=======================================
People think it must be fun to be a super genius, but they don't realize how hard it is to put up with all the idiots in the world. (Calvin from Calvin And Hobbs)

Robert L. Johnson III
CCNA, CCDA, MCSA, CNA, Net+, A+
w: rljohnso@stewart.com
h: wildmage@tampabay.rr.com
 
If however, the data type of the field is a DateTime then the formatting doesn't matter. Use the

Month(eta)

to get the month number.
 
DOH! Golom is right!!! Brain Freeze. Thanks for the assist Golom.

=======================================
People think it must be fun to be a super genius, but they don't realize how hard it is to put up with all the idiots in the world. (Calvin from Calvin And Hobbs)

Robert L. Johnson III
CCNA, CCDA, MCSA, CNA, Net+, A+
w: rljohnso@stewart.com
h: wildmage@tampabay.rr.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top