Skip to content

parseTimestamp

Description

Returns a parsed timestamp from a date or time string, enabling use of DataPrime's time functions.

Note

If the string cannot be parsed (for example, if it does not match the expected format), the function returns null.

Syntax

Like many functions in DataPrime, parseTimestamp supports two notations, function and method notation. These interchangeable forms allow flexibility in how you structure expressions.

parseTimestamp(string: string, format?: string, tz?: string): timestamp
(string: string).parseTimestamp(format?: string, tz?: string): timestamp

Arguments

NameTypeRequiredDescription
stringstringtrueThe string to parse into a timestamp
formatstringfalseThe format of the input string. Defaults to auto, which attempts to match against well-known formats.
tzstringfalseA valid time zone string

Example

Use case 1: Parse a simple date string using default format

choose parseTimestamp('2023-04-05') as ts
choose '2023-04-05'.parseTimestamp() as ts

Output

{
"ts": 1680652800000000000
}