DATE
The DATE data type stores 4-byte calendar date values without any timestamp information.
The range of valid dates is from
01-01-0001
to
12-31-9999
. The default format for returning date values to the client is
YYYY-MM-DD
.
premdb=# create table dates(c1 date);
CREATE TABLE
premdb=# insert into dates values('01-01-0001');
INSERT 0 1
premdb=# insert into dates values('12-31-9999');
INSERT 0 1
premdb=# select * from dates;
c1
------------
0001-01-01
9999-12-31
(2 rows)
See also Formats for Datetime Values.
You can load DATE columns with date values that contain timestamp information, but only the
calendar date is stored and returned in query output. For
example:
premdb=# create table datetest(c1 date);
CREATE TABLE
premdb=# insert into datetest values('2016-05-10 18:20:18.674 PDT');
INSERT 0 1
premdb=# select * from datetest;
c1
------------
2016-05-10
(1 row)