Date/Time Types

Data Type Size Size (Not Null) Synonyms
TIMESTAMP [(p)] [WITHOUTTIMEZONE] 9 bytes 8 bytes  
TIMESTAMP [(p)] [WITHTIMEZONE] 9 bytes 8 bytes TIMESTAMPTZ[(p)]
TIME [(p)] [WITHOUTTIMEZONE] 5 bytes 4 bytes  
TIME [(p)] [WITHTIMEZONE] 9 bytes 8 bytes TIMETZ [(p)]
DATE 5 bytes 4 bytes  

The date and time values are stored in a packed format in the row. The components of the date and time can be accessed via the date and time functions.

The optional precision value (p) in the schema syntax specifies the number of fractional digits to be retained in the seconds field. By default, the precision will be 4 digits. The allowed range of p is from 0 to 4.

DATE

create database testdb;
CREATE TABLE t1 (
   d1 date
);

insert into t1 values (curdate);
select * from t1;
D1
----------
2022-08-26
*** 1 row(s) returned

TIME/TIMETZ

create database testdb;
CREATE TABLE t1 (
   t1 time,
   t2 timetz
);

insert into t1 values (curtime, curtime);
select * from t1;
T1           | T2
-------------+----------------------
18:40:57.1330| 18:40:57.1330 +00:00
*** 1 row(s) returned

TIMESTAMP/TIMESTAMPTZ

create database testdb;
CREATE TABLE t1 (
   ts1 timestamp,
   ts2 timestamptz
);

insert into t1 values (curts, curts);
select * from t1;
TS1                     | TS2
------------------------+--------------------------------
2022-08-26 18:43:20.7590| 2022-08-26 18:43:20.7590 +00:00
*** 1 row(s) returned

See Also

Functions

NULL Values

DEFAULT Values

Limitations