13.2 Date and Time Data Types (original) (raw)

The date and time data types for representing temporal values areDATE,TIME,DATETIME,TIMESTAMP, andYEAR. Each temporal type has a range of valid values, as well as a “zero” value that may be used when you specify an invalid value that MySQL cannot represent. The TIMESTAMP andDATETIME types have special automatic updating behavior, described inSection 13.2.5, “Automatic Initialization and Updating for TIMESTAMP and DATETIME”.

For information about storage requirements of the temporal data types, see Section 13.7, “Data Type Storage Requirements”.

For descriptions of functions that operate on temporal values, seeSection 14.7, “Date and Time Functions”.

Keep in mind these general considerations when working with date and time types:

The following table shows the format of the “zero” value for each type. The “zero” values are special, but you can store or refer to them explicitly using the values shown in the table. You can also do this using the values'0' or 0, which are easier to write. For temporal types that include a date part (DATE,DATETIME, andTIMESTAMP), use of these values may produce warning or errors. The precise behavior depends on which, if any, of the strict andNO_ZERO_DATE SQL modes are enabled; see Section 7.1.11, “Server SQL Modes”.