Icon Date and Time Types

Date and time types are used when you wish to store a date, time, or timestamp (date and time) value.

TypeDescription
DATEA date value containing a year, month, and day.
TIMEA time value containing an hour, minute, second, and millisecond.
TIMESTAMPA combined date and time value containing a year, month, and day along with an hour, minute, second, and millisecond.

Literals
Date and time literals use the IS0 8601 standard which dictates the following formats:

FormatDescription
DATE 'YYYY-MM-DD'YYYY is the 4-digit year, MM is the 2-digit month (1-based), and DD is the 2-digit day (1-based).
TIME 'HH:MM [:SS [.ZZZ AM/PM]]'HH is the 2-digit hour (0-based), MM is the 2-digit minute (0-based), SS is the 2-digit second (0-based), ZZZ is the 3-digit millisecond, or fraction of a second, and AM/PM is the 12-hour time format specifier (as opposed to the default 24-hour time format). The SS, ZZZ, and AM/PM portions of times are optional.
TIMESTAMP '<Date> <Time>'Timestamp literals use the date and time formats with a space between them.

Literal Examples
-- This example specifies a date literal

SELECT * FROM Orders
WHERE OrderDate BETWEEN DATE '2006-01-01' AND DATE '2006-01-31'

-- This example specifies a TIME literal
-- using 24-hour format

SELECT * FROM TimeClockEntries
WHERE PunchInTime > TIME '16:00'

-- This example specifies a TIME literal
-- using 12-hour format

SELECT * FROM TimeClockEntries
WHERE PunchInTime > TIME '4:00 PM'

SQL 2003 Standard Deviations
The following areas are where ElevateDB deviates from the SQL 2003 standard:

DeviationDetails
TIME and TIMESTAMP TypesElevateDB supports including the AM or PM (case-insensitive) indicator for indicating 12-hour time formats.
TIME and TIMESTAMP TypesElevateDB does not support specifying the precision of a time or timestamp value and always includes the millisecond portion.
WITH TIME ZONE TypesElevateDB does not support the time zone versions of the TIME and TIMESTAMP types.
Image