Categories:

コンテキスト関数 (General)

SYSDATE

Returns the current timestamp for the system, but in the UTC time zone.

See also:

CURRENT_TIMESTAMP

Syntax

SYSDATE()

Arguments

None.

Returns

Returns the current timestamp in the UTC time zone.

The data type of the returned value is TIMESTAMP_NTZ.

Usage Notes

  • Despite the name, this returns a TIMESTAMP_NTZ, not a DATE. To control the output format, use the session parameter TIMESTAMP_NTZ_OUTPUT_FORMAT.

  • This function is similar to CURRENT_TIMESTAMP, except that:

    • It returns the current timestamp in the UTC time zone, whereas CURRENT_TIMESTAMP returns the timestamp in the local timezone.

    • Its return value is TIMESTAMP_NTZ, whereas CURRENT_TIMESTAMP returns TIMESTAMP_LTZ.

    • It requires parentheses (SYSDATE()), whereas CURRENT_TIMESTAMP can be called without parentheses.

    • It does not support a parameter to specify the precision of fractional seconds.

  • Do not use the returned value for precise time ordering between concurrent queries (processed by the same virtual warehouse) because the queries might be serviced by different servers (in the warehouse).

Examples

Set the time output format to YYYY-MM-DD HH24:MI:SS.FF4, then return the SYSDATE and CURRENT_TIMESTAMP. Note the difference in the hour field due to the difference in time zone.

ALTER SESSION SET TIMESTAMP_NTZ_OUTPUT_FORMAT = 'YYYY-MM-DD HH24:MI:SS.FF4';
ALTER SESSION SET TIMESTAMP_LTZ_OUTPUT_FORMAT = 'YYYY-MM-DD HH24:MI:SS.FF4';

ALTER SESSION SET TIMEZONE = 'America/Los_Angeles';

SELECT SYSDATE(), CURRENT_TIMESTAMP();

+--------------------------+--------------------------+
| SYSDATE()                | CURRENT_TIMESTAMP()      |
|--------------------------+--------------------------|
| 2019-12-23 08:00:00.1230 | 2019-12-23 00:00:00.1230 |
+--------------------------+--------------------------+