Appearance
TIMESTAMP
The TIMESTAMP data type stores 8-byte date values that include timestamp information in UTC format but no time zone information. You can load TIMESTAMP columns with time zone information, but the time zone is not stored or returned in query output.
You cannot define a TIMESTAMP column with a specific precision for fractional seconds other than 6. A valid timestamp includes up to 6 digits of precision. If additional fractional digits exist in input values, the timestamp is rounded up or down, as appropriate.
For example, the following CREATE TABLE statements are allowed and produce the same table:
premdb=# create table timestamps6(c1 timestamp(6));
CREATE TABLE
premdb=# create table timestamps(c1 timestamp);
CREATE TABLE
The following CREATE TABLE statement is disallowed:
premdb=# create table timestamps(c1 timestamp(4));
ERROR: TIMESTAMP with precision 4 is not allowed, only 6 is supported
The following examples show the behavior when different values are inserted into a TIMESTAMP column. The range of valid dates in timestamps is from 01-01-0001
to 12-31-9999
.
Inserted Value | Stored Value | Notes |
---|---|---|
2016-05-10 18:20:18.674 PDT | 2016-05-10 18:20:18.674 | The PDT time zone is removed. |
2016-05-11 2:30 | 2016-05-11 02:30:00 | By default, :00 is added for seconds. A leading zero is added for the hours (02 ). |
2016-05-11 2:31:59.99999 | 2016-05-11 02:31:59.99999 | Loaded as is, with 5 digits of precision for fractional seconds. A leading zero is added for the hours (02 ). |
2016-05-11 2:31:59.999999 | 2016-05-11 02:31:59.999999 | Loaded as is, with a maximum 6 digits of precision for fractional seconds. A leading zero is added for the hours (02 ). |
2016-05-11 2:31:59.9999999 | 2016-05-11 02:32:00 | Too many digits (7) for fractional seconds. The timestamp is rounded up. |
Parent topic:SQL Data Types