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

Convert text month and year to real date 2

Status
Not open for further replies.

honeypot3

Instructor
Feb 8, 2005
77
GB
Hi there

I have two separate fields called [month] and [year] set as text data types for ease of use on a user form. However in a query I need to be able to combine and convert the month and year text values into a recognisable date so they can be used in date calculations. Is there a way to do this?
 
Take a look at the DateSerial function.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Suggesting that your [Month] field is text is still vague. You could be storing values like:
1
01
Jan
January

In addition to DateSerial(), you may need to consider CDate().

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Thanks PHV will give it a go.

Duane - the months are in the format Jan, Feb, Mar etc. the user simply selects them from a combo box so there would be no variance. Will DateSerial be OK for this?
 
Duane was right, use CDate:
CDate([year] & "-" & [month] & "-01")

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top