StringToDate Function

The StringToDate function converts a string value to a datetime object. Some use cases could include if your date is improperly stored as a string in your data extension and you want to convert it to a proper datetime format.



1 = String value (can be a variable)
2 = Character set for encoding. Defaults to UTF-8 but can use UTF-16




var @string
set @string = “2021-01-13 09:00 PM”



1/13/2021 9:00:00 PM


In the AMPscript above, first we are declaring the variables using the var function. Then defining the @string variable as the string: “2021-01-13 09:00 PM”

The output of that value returned in datetime object as 1/13/2021 9:00:00 PM

Leave a Reply

Your email address will not be published. Required fields are marked *