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!

Converting date formats within VBA

Status
Not open for further replies.

paulwoods23

IS-IT--Management
Jan 21, 2003
5
GB
I currently use a short date in UK format (dd/mm/yy) in a On Click event from a form to use in a query within some VB code. But this date is then used in US format (mm/dd/yy). How do I convert it back to UK format within the code so that the output is correct?
I tried the following to convert it -

Code:
Dim DateConv As Date
DateConv = Format(Me.SDate, "dd/MM/yy")

Then used DateConv instead of Me.Sdate.
But it didn't work. Any ideas?
 
OK, it seems to me that you need to format your output, not your input. You need to place your format code in your query, not in your input.
Trisha
padinka@yahoo.com
 
I see what you mean, the query was reading a UK format as a US format so I needed to convert it to US format within the query.

I used
Format(Me.SDate, "mm dd yyyy")
and it worked a treat.

Thanks for the tip.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top