The TIMESTAMP data type represents date and time of day data.
TIMESTAMP values range from January 1, -8192 through December 31, 8191, to an accuracy of one hundred nanoseconds (one ten-thousandth of a millisecond).
TIMESTAMP values can be restricted to represent date data only or time of day data only.
As explained in the Remarks section below, a TIMESTAMP value that has been restricted to represent date data only or time of day data only will be formatted to display date elements only (year, month, and day) or time of day elements only (hour, minute, second, millisecond, and nanosecond).
TIMESTAMP values can be restricted to date-only or time-only timestamps in different ways.
Some input formats return TIMESTAMP input record fields whose values represent only dates or times of day. For example, the "date" and "time" fields of the IISW3C input format have values representing only dates and times of day, respectively.
TIMESTAMP constants can also be entered as date-only or time-only timestamp values, depending on the Timestamp Format Specifiers used.
In addition, the TO_DATE, TO_TIME, SYSTEM_DATE, and SYSTEM_TIME functions all return TIMESTAMP values representing dates or times of day only.
For more information, refer to the Remarks section below.
SELECT TO_STRING(time, 'yyyy-MM-dd hh:mm:ss') FROM <1>Since the values of the "time" field are time-only TIMESTAMP values, the resulting STRING values will be formatted according to the time of day format specifiers only, and the date format specifiers will be ignored:
18:48:04 18:48:27 18:48:27 18:48:29
SELECT * FROM SYSTEM WHERE TimeWritten > TO_LOCALTIME( SUB( SYSTEM_TIMESTAMP(), TIMESTAMP('0000-01-03', 'yyyy-MM-dd') ) )
Other data types to TIMESTAMP data type:
TIMESTAMP data type to other data types:
Full TIMESTAMP values to date-only TIMESTAMP values:
Full TIMESTAMP values to time-only TIMESTAMP values:
Date-only and time-only TIMESTAMP values to full TIMESTAMP values:
Local timezone TIMESTAMP values to UTC TIMESTAMP values:
UTC TIMESTAMP values to local timezone TIMESTAMP values:
© 2004 Microsoft Corporation. All rights reserved.