postgresql_16:3.5.5 Date/Time Types
PostgreSQL 16 > The SQL Language > Data Types > Date/Time Types
PostgreSQL supports the full set of SQL date and time types, shown in (see datatype-datetime-table). The operations available on these data types are described in (see postgresql_16:3.6.9). Dates are counted according to the Gregorian calendar, even in years before that calendar was introduced (see (see postgresql_16:9.2.6) for more information).
| Name | Storage Size | Description | Low Value | High Value | Resolution | | --- | --- | --- | --- | --- | --- | | timestamp [ (*p*) ] [ without time zone ] | 8 bytes | both date and time (no time zone) | 4713 BC | 294276 AD | 1 microsecond | | timestamp [ (*p*) ] with time zone | 8 bytes | both date and time, with time zone | 4713 BC | 294276 AD | 1 microsecond | | date | 4 bytes | date (no time of day) | 4713 BC | 5874897 AD | 1 day | | time [ (*p*) ] [ without time zone ] | 8 bytes | time of day (no date) | 00:00:00 | 24:00:00 | 1 microsecond | | time [ (*p*) ] with time zone | 12 bytes | time of day (no date), with time zone | 00:00:00+1559 | 24:00:00-1559 | 1 microsecond | | interval [ *fields* ] [ (*p*) ] | 16 bytes | time interval | -178000000 years | 178000000 years | 1 microsecond |
Note
The SQL standard requires that writing just timestamp be equivalent to timestamp without time zone, and PostgreSQL honors that behavior. timestamptz is accepted as an abbreviation for timestamp with time zone; this is a PostgreSQL extension.
time, timestamp, and interval accept an optional precision value *p* which specifies the number of fractional digits retained in the seconds field. By default, there is no explicit bound on precision. The allowed range of *p* is from 0 to 6.
The interval type has an additional option, which is to restrict the set of stored fields by writing one of these phrases: YEAR MONTH DAY HOUR MINUTE SECOND YEAR TO MONTH DAY TO HOUR DAY TO MINUTE DAY TO SECOND HOUR TO MINUTE HOUR TO SECOND MINUTE TO SECOND Note that if both *fields* and *p* are specified, the *fields* must include SECOND, since the precision applies only to the seconds.
The type time with time zone is defined by the SQL standard, but the definition exhibits properties which lead to questionable usefulness. In most cases, a combination of date, time, timestamp without time zone, and timestamp with time zone should provide a complete range of date/time functionality required by any application.
Subsections
- postgresql_16:3.5.5.1 Date/Time Input
- postgresql_16:3.5.5.2 Date/Time Output
- postgresql_16:3.5.5.3 Time Zones
- postgresql_16:3.5.5.4 Interval Input
- postgresql_16:3.5.5.5 Interval Output