The toDate function takes an expression as an argument, and returns the expression (containing a date-time value) in the date format as specified in application settings.
This function takes an optional argument dateTimeMapping when the given expression is of text data type. It is used to denote the date-time components for which the values in the text stand for.
<variable> = <expression>.toDate(<dateTimeMapping>);
<variable> = toDate(<expression>, <dateTimeMapping>);
|<variable>||DATE-TIME||Variable which will contain the returned date value.|
The expression (containing a valid date time format) which will be returned in date format.
When the data type is NUMBER:
When the data type is Date-Time, the additional parameters (mentioned below) are ignored. And, the function will throw a runtime error if the month value exceeds the number of months in a year, or the day value exceeds the number of days in a month.
The format in which the date-time value must be represented.
Applies when the given expression is of Text data type.
You can specify date-time literals (as mentioned in the below table) to denote the date value components in the expression as required. The pattern letters must be separated using the exact same separator as given in the expression.
When the month is specified as numerical value, the month pattern letter "M" must be specified as M or MM.
When the month is specified as a text value, the month pattern letter "M" must be specified as MMM (or may contain more number of M's).
|Literal||Date and Time component|
|M||Month of the year|
|d||Day of the month|
dateTimeString = "01,11,2019 1:30:00 pm"; info toDate(dateTimeString, "MM,d,yyyy"); // MM,d,yyyy is to denote the components in the expression // So the value for MM is 01 (January), the value for d is 11, and the value for yyyy is 2019 // Assuming that the date time format set in application settings is dd-MMM-yyyy, the value returned is 11-Jan-2019