views:

3537

answers:

2

I have a string of "DD/MM/YYYY HH:MM:SS" which I need to transform to a date, the problem is the default conversion goes "MM/DD/YYYY HH:MM:SS" unless the day is >12 in which case it switches. I'd like to ensure that my day's go into the day portion of the date/time.

Is there an easy fix to this?

+1  A: 

use the format function

this could do it too

Fredou
the format function only works with vba :-(The other one might work, but I'll manually have to break apart the string, I was hoping not to.
Nathan Koop
A: 
' Parse a date in ISO 8601 "universal combined" format: YYYY-MM-DDTHH:MM:SSZ
' This function ALSO accepts SQL date format:  YYYY-MM-DD HH:MM:SS
Function CDateFromUniversal( s )

    CDateFromUniversal = CDate(Mid(s, 1, 10) & " " & Mid(s, 12, 8))

End Function
Michael Pryor