util.Datetime.parse

Converts a string to a DATETIME value based on a specified format.

Syntax

util.Datetime.parse(
  s STRING,
  format STRING
)
  RETURNS DATETIME q1 TO q2
  1. s is the source string to be parsed.
  2. format is the format specification (see Formatting DATETIME values).

Usage

The util.Datetime.parse() method parses a string based on a format specification, to produce a DATETIME value.

The format specification must be a combination of place holders such as %Y, %m, %d, etc.

The precision of the resulting DATETIME value depends on the format specification. For example, when using "%y-%m-%d %H:%M", the resulting value will be a DATETIME YEAR TO MINUTE.

The method returns NULL, if the source string cannot be converted to a DATETIME value depending on to the format specification.

For more details about the supported formats, see Formatting DATETIME values.

Example

IMPORT util
MAIN
    DEFINE dt DATETIME YEAR TO MINUTE
    LET dt = util.Datetime.parse( "2014-12-24 23:45", "%Y-%m-%d %H:%M" )
    DISPLAY dt
END MAIN