Full Version: Format Date field
UtterAccess Discussion Forums > Microsoft® Access > Access Queries
H925M
I have a date field with the format "20010925" or "yyyymmdd" and need to this change. it's currently a text field and I need it to be a date field with the format mm/yyyy. Any ideas on how to change this? Thanks for your help!
jwhite
You want to use the Left and Mid functions. But, your new format of "mm/yyyy" is not a proper "date field".

NewValue = Mid(YourField,5,2) & "/" & Left(YourField,4)

That will save it to a String Variable, and work if the Month is ALWAYS 2 digits.

For a proper Date Field:

NewValue = CDate(Mid(YourField,5,2) & "/" & Right(YourField,2) & "/" & Left(YourField,4))
H925M
Ok, great! I will try that. Thanks for your help!
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.