asDateTime
Converts the input value to a datetime object.
Returns null if the input value cannot be converted.
To create a datetime object from a string in a non-recognized datetime pattern, use parseDateTime instead.
Parameters
X (string or table cell)
The value to convert.
Examples
Each example uses a string in an automatically recognized datetime pattern.
ATL in Script | Result |
---|---|
| 8:00:00 AM |
| 12:00:00 PM |
| 12:00:00 AM |
| Jan 23, 2018 |
| Dec 2, 2018 7:30:24 AM |
The return value in each case is a datetime object. By default, Studio prints datetime objects by applying the MMM d, yyyy HH:mm:ss a
format pattern. To change the object's display format, use formatDateTime.
ATL in Script | Result |
---|---|
[[ dateTimeString = '2018-12-02T07:30:24'; dateTimeObject = asDateTime(dateTimeString); formatDateTime(dateTimeObject, 'EEEE, d MMMM yyyy') ]] | Sunday, 2 December 2018 |