PARSE_DATETIME

Parses a string into a timestamp with time zone using format.

Syntax

PARSE_DATETIME(input, format)

Arguments

NameTypeDescriptionDefault Value

input

string

format

string

Returns

Returns a timestamp value.


Examples

inputformatOutput

'2017-09-25 22:11:00'

'yyyy-MM-dd HH:mm:ss'

timestamp '2017-09-25 22:11:00'

'2018-03-19'

'yyyy-MM-dd'

timestamp '2018-03-19 00:00:00'

'2018_Mar_21'

'yyyy_MMM_dd'

timestamp '2018-03-21 00:00:00'

'2018_Mar_21_17:59:05.689'

'yyyy_MMM_dd_HH:mm:ss.SSS'

timestamp '2018-03-21 17:59:05.689'

'2012/02/22 12:34:56'

'Y/MM/d HH:mm:ss'

timestamp '2012-02-22 12:34:56'

'01-06-2021'

'dd-MM-YYYY'

timestamp '2021-06-01 00:00:00'

'01-06-2021'

'MM-dd-YYYY'

timestamp '2021-01-06 00:00:00'

'2021-05-13 19:02:57.415006+01:00'

'YYYY-MM-dd HH:mm:ss.SSSSSSZ'

timestamp '2021-05-13 18:02:57.415'

Transformation job example

SQL

CREATE JOB function_operator_example
    ADD_MISSING_COLUMNS = true
AS INSERT INTO default_glue_catalog.upsolver_samples.orders_transformed_data 
  MAP_COLUMNS_BY_NAME
    SELECT input, format,
        PARSE_DATETIME(input, format) AS Output
    FROM default_glue_catalog.upsolver_samples.orders_raw_data
    LET input = '2017-09-25 22:11:00',
        format = 'yyyy-MM-dd HH:mm:ss'
    WHERE $commit_time BETWEEN run_start_time() AND run_end_time()
    LIMIT 1;

Query result

inputformatOutput

'2017-09-25 22:11:00'

'yyyy-MM-dd HH:mm:ss'

timestamp '2017-09-25 22:11:00'

Last updated