util.Interval.parse

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

Syntax

util.Interval.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 INTERVAL values).

Usage

The util.Interval.parse() method parses a string according to a format specification, to produce an INTERVAL value.

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

The precision of the resulting INTERVAL value depends on the format specification. For example, when using "%Y-%m", the resulting value will be an INTERVAL YEAR TO MONTH.

The method returns NULL, if the source string cannot be converted to an INTERVAL value according to the format specification.

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

Example

IMPORT util
MAIN
    DEFINE iv INTERVAL DAY(6) TO FRACTION(5)
    LET iv = util.Interval.parse( "-37467 + 23:45:34.12345", "%d + %H:%M:%S%F5" )
END MAIN