Nathan Koop
Nathan Koop

Reputation: 25197

cast string to date time in classic asp

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?

Upvotes: 0

Views: 13765

Answers (2)

Michael Pryor
Michael Pryor

Reputation: 25346

' 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

Upvotes: 1

Fredou
Fredou

Reputation: 20110

use the format function

this could do it too

Upvotes: 0

Related Questions