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!

Changing Date Format

Status
Not open for further replies.

breukelen

Technical User
Oct 31, 2001
54
NL
Good morning,

I like to change my Dutch style dates into USA style dates.
example:
22-mrt-02 into 22-mar-02
23-mei-02 into 23-may-02

Thanks in advance for your help.

Gunter

 
Hi Gunter,

Try this. I placed this on the AfterUpdate event of a field on the form. [fieldname] would be = to Forms!frmFormName!fieldname.

Function MyNewDate()
Dim MyDay as string
Dim MyMonth as string
Dim MyYear as string
Dim NewDate as string

MyDay = Left([fieldname],3)
MyMonth = Mid([fieldname],4,3)
MyYear = Right([fieldname],3)

Select case MyMonth
Case "mrt"
NewDate = MyDay & "Mar" & MyYear
Case "mei"
NewDate = MyDay & "May" & MyYear
End Select

[fieldname] = NewDate

End Function

This would work as long as you always used 2 characters for the day of the month (01, 02, 03, etc) and as long as you always used 3 characters for the month (mrt, mei, etc - I don't know the rest sorry). You would have a "Case" for all 12 months.
This function should parse out the month value and replace it with the value in quotes in each case. At the end, [fieldname] = NewDate, this is where you are replacing the value in the fieldname.

Hope this gives you some ideas!! I am sure that there is probably a way to do it easier, but I do not know how.

Good Luck!

Lee

 
Check this link.

Functions in Access to convert date and time.
Format
FormatDateTime

Check the syntax for these functions in Access help. Also, look at the formatting options under help. Since the date/time is stored in the database regardless of your formatting, I am guessing that you want to convert the date to us english for the query criteria expression and then back to dutch for display to your users. The format functions can be used in both cases.
 
Lee ,

Thanks for your help.I will try it out.
Happy Eastern.

Gunter
 
Lee ,

Your solution worked very good.
Thanks again !!

Gunter
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top