TIME Data Type

Description

A variable of type TIME holds values for a hours, minutes, seconds, and microseconds.

Notes

You can use relational operators between two variables of type TIME. You can cast a variable of type TIME to or from a type DATETIME. If you cast from a type DATETIME to a TIME, you lose the date information. If you cast from a TIME to a DATETIME, the DATE portion defaults to the current date.

You can generate a TIME constant by specifying a time as a string and then casting the string as a TIME data type. The string must have the ISO format, as follows:

"HH:MM:SS.MSMSMS"

This is an implicit type cast and so does not require the type cast operator (the square brackets). You can truncate the string at any point, as long as the last field is complete.

See the DATETIME data type for a summary of the rules that govern the various ways in which you can convert dates and times using casting.