toDate()

toDate()

Overview

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.

Return Type

  • Date-time

Syntax

<variable> = <expression>.toDate( <dateTimeMapping> );

(OR)

<variable> = toDate( <expression>, <dateTimeMapping> );
ParameterDescriptionData type
<variable>Variable which will contain the returned date value.DATE-TIME
<expression>

The expression (containing a valid date time format) which will be returned in date format.

When the data type is NUMBER:

  • the number 1 stands for the date-time value 31-Dec-1969, and every increase in 1000 will add 1 second to the date value, and every decrease in 1000 will subtract 1 second from the date value. So, the number 1000 will return a date value of 31-Dec-1969.
  • the dateTimeMapping param is ignored.

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.

TEXT

NUMBER

DATE-TIME

<dateTimeMapping>

(optional)

Applies when the given expression is of Text data type. 

You can specify pattern letters (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).

TEXT

Applicable pattern letters

Letter           Date and Time component
yYear
MMonth in year
dDay in month

Examples

dateTimeString = "01,11,19 1:30:00 pm"; 
dateTime = toDate(dateTimeString, "MM,d,yyyy");         

//Assuming, date time format set in application settings is dd-MMM-yyyy
//returns 11-Jan-0019

Share this post : FacebookTwitter

Still can't find what you're looking for?

Write to us: support@zohodeluge.com