Spec-Zone .ru
спецификации, руководства, описания, API

11.3. Date and Time Types

11.3.1. The DATE, DATETIME, and TIMESTAMP Types
11.3.2. The TIME Type
11.3.3. The YEAR Type
11.3.4. YEAR(2) Limitations and Migrating to YEAR(4)
11.3.5. Automatic Initialization and Updating for TIMESTAMP andDATETIME
11.3.6. Fractional Seconds in Time Values
11.3.7. Conversion Between Date and Time Types
11.3.8. Two-Digit Years in Dates

The date and time types for representing temporal values are DATE, TIME, DATETIME, TIMESTAMP, and YEAR. 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 type has special automatic updating behavior, described later. For temporal type storage requirements, see Section 11.6, "Data Type Storage Requirements".

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, and TIMESTAMP), use of these values produces warnings if the NO_ZERO_DATE SQL mode is enabled.

Data Type "Zero" Value
DATE '0000-00-00'
TIME '00:00:00'
DATETIME '0000-00-00 00:00:00'
TIMESTAMP '0000-00-00 00:00:00'
YEAR 0000