Clock Timestamp
Date/Time Function
Description
Return a timestamp equivalent to the current time including time zone.
Click here to navigate to the PostgreSQL docs page for this syntax.
Grammar Syntax
CLOCK_TIMESTAMP()
Sample Source Patterns With SELECT Query.
Postgre
SELECT clock_timestamp();
Snowflake
ALTER SESSION SET timestamp_output_format = 'YYYY-MM-DD HH24:MI:SS.FF';
SELECT
CURRENT_TIMESTAMP(3);
Sample Source Patterns With CREATE TABLE.
Timestamp
Postgre
CREATE TABLE table1 (
dt_update timestamp without time zone DEFAULT clock_timestamp()
);
Snowflake
CREATE TABLE table1 (
dt_update TIMESTAMP_NTZ DEFAULT
/*** MSC-INFORMATION - MSCINF0039 - THE DATE OUTPUT FORMAT MAY VARY DEPENDING ON THE TIMESTAMP TYPE AND THE TIMESTAMP_OUTPUT_FORMAT BEING USED. ***/
CURRENT_TIMESTAMP() :: TIMESTAMP_NTZ
);
Date, Time, and Interval
Postgre
CREATE TABLE table1 (
dt_update date DEFAULT clock_timestamp()
);
Snowflake
CREATE TABLE table1 (
dt_update date DEFAULT
/*** MSC-INFORMATION - MSCINF0039 - THE DATE OUTPUT FORMAT MAY VARY DEPENDING ON THE TIMESTAMP TYPE AND THE TIMESTAMP_OUTPUT_FORMAT BEING USED. ***/
CURRENT_TIMESTAMP() :: DATE
);
Observations
In the case of a select with clock_timestamp, ALTER SESSION is added to maintain compatibility with the PostgreSQL, Greenplum, and Redshift formats. And a precision of 3 is added to the CURRENT_TIMESTAMP for the same reason.
MSCINF0039 is added because when a SELECT is executed to the table the format may vary.
The TIMESTAMP_NTZ type is not affected by the ALTER SESSION set timestamp_output_format.
The ALTER SESSION set timestamp_output_format only affects the TIMESTAMP_LTZ and TIMESTAMP_TZ types when a SELECT statement is executed on the specific table. Their precision, which is set to 9 by default, remains unchanged.
Related EWIs
MSCINF0039: The date output format may vary.
MSCEWI1002: Removed next statement, not applicable in SnowFlake.
MSCEWI1096: TIME ZONE not supported for time data type.
MSCEWI1036: Data type converted to another data type.
Last updated
Was this helpful?