util.Datetime.parse

Converts a string to a DATETIME value according to a format specification.

Syntax

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

Usage

The util.Datetime.parse() method parses a string according to 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 according 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