In SQL, a temporal value is either a datetime (i.e.: a date, a clock time or a
timestamp) or an interval (i.e.: a span of time). They consist of a contiguous
subset of one or more of the datetime fields (in their order of significance):
YEAR, MONTH, DAY,
HOUR, MINUTE, SECOND,
TIMEZONE_HOUR and TIMEZONE_MINUTE. A
temporal value may be a <literal>, the value of a parameter or a host language
variable or the result of any expression or argument (including a possibly
qualified <Column name>) that evaluates to a date, a time, a timestamp or an
interval. Temporal values are constrained by their datetime fields and must
obey the natural rules for dates and times according to the Gregorian calendar.
Datetimes are either dates, times or timestamps. Dates are stored in the
DATE <data type>, times are stored in either the
TIME or the TIME WITH TIME ZONE <data
type>s and timestamps are stored in either the TIMESTAMP or
the TIMESTAMP WITH TIME ZONE <data type>s.
Intervals are either year-month intervals (spans of time involving years
and/or months) or day-time intervals (spans of time involving days and/or
hours and/or minutes and/or seconds and/or fractions of a second); they
include a qualifier which specifies which of the datetime fields are
represented in the interval. All interval values are signed. Intervals are
stored in the INTERVAL <data type>.
-
Some Preliminaries
Before we talk about datetimes and intervals, there is some necessary back... -
Temporal <literal>s
A temporal <literal> is any temporal value in one of two categories: datet... -
Temporal <data type>s
A temporal <data type> is either a datetime <data type> or an interval <da... -
Temporal Operations
A temporal value is only compatible with, and comparable to, a matching te... -
Dialects
The "typical" SQL DBMS supports date, time and timestamp data types but int... -
The SQL Library
Before we finish discussing temporal values, it's time to add something to ...