DATE_TRUNC

Truncate a date to a given time unit.

Syntax

DATE_TRUNC(unit, time)

Arguments

Returns

timestamp


Examples

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 unit, time,
        DATE_TRUNC(unit, time) AS Output
    FROM default_glue_catalog.upsolver_samples.orders_raw_data
    LET unit = 'millisecond',
        time = timestamp '2021-02-03 04:05:06.789'
    WHERE $commit_time BETWEEN run_start_time() AND run_end_time()
    LIMIT 1;

Query result

Last updated