(mysql.info.gz) Date and time type overview
Info Catalog
(mysql.info.gz) Numeric type overview
(mysql.info.gz) Column type overview
(mysql.info.gz) String type overview
11.1.2 Overview of Date and Time Types
--------------------------------------
A summary of the temporal column types follows. For additional
information, see Date and time types. Column storage
requirements are given in Storage requirements.
`DATE'
A date. The supported range is `'1000-01-01'' to `'9999-12-31''.
MySQL displays `DATE' values in `'YYYY-MM-DD'' format, but allows
you to assign values to `DATE' columns using either strings or
numbers.
`DATETIME'
A date and time combination. The supported range is `'1000-01-01
00:00:00'' to `'9999-12-31 23:59:59''. MySQL displays `DATETIME'
values in `'YYYY-MM-DD HH:MM:SS'' format, but allows you to assign
values to `DATETIME' columns using either strings or numbers.
`TIMESTAMP[(M)]'
A timestamp. The range is `'1970-01-01 00:00:00'' to partway
through the year `2037'.
A `TIMESTAMP' column is useful for recording the date and time of
an `INSERT' or `UPDATE' operation. The first `TIMESTAMP' column in
a table is automatically set to the date and time of the most
recent operation if you don't assign it a value yourself. You can
also set any `TIMESTAMP' column to the current date and time by
assigning it a `NULL' value.
From MySQL 4.1 on, `TIMESTAMP' is returned as a string with the
format `'YYYY-MM-DD HH:MM:SS''. If you want to obtain the value as
a number, you should add `+0' to the timestamp column. Different
timestamp display widths are not supported.
In MySQL 4.0 and earlier, `TIMESTAMP' values are displayed in
`YYYYMMDDHHMMSS', `YYMMDDHHMMSS', `YYYYMMDD', or `YYMMDD' format,
depending on whether M is 14 (or missing), 12, 8, or 6, but allows
you to assign values to `TIMESTAMP' columns using either strings
or numbers. The M argument affects only how a `TIMESTAMP' column
is displayed, not storage. Its values always are stored using
four bytes each. From MySQL 4.0.12, the `--new' option can be used
to make the server behave as in MySQL 4.1.
Note that `TIMESTAMP(M)' columns where M is 8 or 14 are reported to
be numbers, whereas other `TIMESTAMP(M)' columns are reported to be
strings. This is just to ensure that you can reliably dump and
restore the table with these types.
`TIME'
A time. The range is `'-838:59:59'' to `'838:59:59''. MySQL
displays `TIME' values in `'HH:MM:SS'' format, but allows you to
assign values to `TIME' columns using either strings or numbers.
`YEAR[(2|4)]'
A year in two-digit or four-digit format. The default is
four-digit format. In four-digit format, the allowable values are
`1901' to `2155', and `0000'. In two-digit format, the allowable
values are `70' to `69', representing years from 1970 to 2069.
MySQL displays `YEAR' values in `YYYY' format, but allows you to
assign values to `YEAR' columns using either strings or numbers.
The `YEAR' type is unavailable prior to MySQL 3.22.
Info Catalog
(mysql.info.gz) Numeric type overview
(mysql.info.gz) Column type overview
(mysql.info.gz) String type overview
automatically generated byinfo2html