Skip to main content

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

[[asDateTime('08:00')]]

8:00:00 AM

[[asDateTime('12:00')]]

12:00:00 PM

[[asDateTime('00:00')]]

12:00:00 AM

[[asDateTime('2018-01-23')]]

Jan 23, 2018

[[asDateTime('2018-12-02T07:30:24')]]

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