Im trying to write a Date Function that strips the date from its source format (DD/MM/YYYY) with datatype Date, and converts it into the format (YYYY-MM-DD) with datatype String.
eg. xDate = 01/10/2002 (1 OCT 2002) should convert to string '2002-10-01'
Here's my code to do this:
Function ParseDate(xDate As Date) As String
ParseDate = CStr(Format(xDate, "yyyy-mm-dd", vbMonday))
Debug.Print ParseDate
End Function
When i pass a date, instead of seeing a date it treats the passed parameter like an equation. So parameter 01/10/2002 is the same as 0.00004995 which has a Date equivalent of 30-DEC-1899. Not what I was after !?![[sad] [sad] [sad]](/data/assets/smilies/sad.gif)
What's missing from my function?
L.
eg. xDate = 01/10/2002 (1 OCT 2002) should convert to string '2002-10-01'
Here's my code to do this:
Function ParseDate(xDate As Date) As String
ParseDate = CStr(Format(xDate, "yyyy-mm-dd", vbMonday))
Debug.Print ParseDate
End Function
When i pass a date, instead of seeing a date it treats the passed parameter like an equation. So parameter 01/10/2002 is the same as 0.00004995 which has a Date equivalent of 30-DEC-1899. Not what I was after !?
![[sad] [sad] [sad]](/data/assets/smilies/sad.gif)
What's missing from my function?
L.