DATE Data Type

Description

A variable of type DATE holds values for a calendar year, month, and day. The DATE data type represents values from 4713 B.C.E (B.C.) to 19999 C.E. (A.D.).

For the range of valid values, see Data type ranges.

Notes

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

You can generate a DATE constant by specifying a date as a string and then casting the string as a DATE data type. The string must have the following format:

"YYYY-MM-DD"

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 DATETIME Data Type for a summary of the rules that govern the various ways in which you can convert dates and times using casting.