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

Parsing out the month and the year from a date 1

Status
Not open for further replies.

mohebk

MIS
Aug 23, 2005
139
US
Hi,
I have a column that has data that looks like this:
5/19/1999
6/4/1998
11/4/2001
12/13/2005

I would like to write an update query that would insert only the month and the year in a new column called PostMMYYYY. The new column would have these values:
51999
61998
112001
122005

Please help(MS Access 2003).

Thanks


Mo

Mo
 
The source field is called PostDate and it is a date field. The target field is called PostMMYYYY and it is a text field.

Thanks

Mo
 
Try this. Put this in your update query. Replace "FieldName" with the name of your field that contains your traditional dates.

PostMMYYYY: Format([FieldName],"myyyy")
 
Something like:

UPDATE YourTable
SET PostMmyyyy = Format ("Postdate", "mmyyyy")

will do it:
 
Whether your data is text or a date field, and the field name is DateText:

Month(DateText) -- will give you the month number
Year(DateText) -- will give you the year number

then concatenate the results

month(DateText) & year(datetext)

 
mmogul's solution worked great. Thank you all for your great input.

Mo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top