Real Date format

IanT

Registered User.
Local time
Today, 06:49
Joined
Nov 30, 2001
Messages
191
I am using this code to convert a string date to real date.

Dim newDate As String
newDate = Left(strDate, 2) & "/" & Mid(strDate, 4, 2) & "/" & Right(strDate, 4)
ConvertDate = newDate

The problem is that if the format of the date is not like dd/mm/yyyy (10/10/2005) the code errors. Can anyone advise how to overcome this, the date can be in other formats ie d/mm/yyyy (5/10/2005. I was considering a select code but unsure how to identify the different formats.
 
Have you tried using the DateValue(str) function? This converts a string to Date format.
 
Format(DateValue(strDate), "dd/mm/yyyy")
 

Users who are viewing this thread

Back
Top Bottom