Oracle 5.0 Reference Manual page 867

Table of Contents

Advertisement

Conversion of
• Conversion to a
information.
• Conversion to a
information.
Conversion of
MySQL converts a time value to a date or date-and-time value by parsing the string value of the time
as a date or date-and-time. This is unlikely to be useful. For example,
date becomes '2032-12-31'. Time values not valid as dates become
Prior to MySQL 5.0.42, when
the
DATETIME
from MySQL 5.0.42, a
'00:00:00'. To mimic the old behavior, use the
operands to be treated as previously. For example:
date_col
=
CAST(datetime_col
As of MySQL 5.0.8, conversion of
+0) results in a double-precision value with a microseconds part of .000000:
mysql>
SELECT CURTIME(), CURTIME()+0;
+-----------+---------------+
| CURTIME() | CURTIME()+0
+-----------+---------------+
| 10:41:36
+-----------+---------------+
mysql>
SELECT NOW(), NOW()+0;
+---------------------+-----------------------+
| NOW()
+---------------------+-----------------------+
| 2007-11-30 10:41:47 | 20071130104147.000000 |
+---------------------+-----------------------+
Before MySQL 5.0.8, the conversion results in an integer value with no microseconds part.
11.1.5.8. Two-Digit Years in Dates
Date values with two-digit years are ambiguous because the century is unknown. Such values must be
interpreted into four-digit form because MySQL stores years internally using four digits.
For DATETIME, DATE, and
values using these rules:
• Year values in the range
• Year values in the range
For YEAR, the rules are the same, with this exception: A numeric
rather than 2000. To specify zero for
0000
string
or '00'.
'0'
Remember that these rules are only heuristics that provide reasonable guesses as to what your data
values mean. If the rules used by MySQL do not produce the values you require, you must provide
unambiguous input containing four-digit year values.
properly sorts
ORDER BY
Some functions like
value with a two-digit year does not work properly with these functions. The fix in this case is to convert
the
to four-digit year format.
YEAR
Date and Time Types
and
DATETIME
TIMESTAMP
value discards the time part because the
DATE
value discards the date part because the
TIME
values:
TIME
values are compared with
DATE
value is ignored, or the comparison could be performed as a string compare. Starting
value is coerced to the
DATE
AS DATE)
TIME
|
| 104136.000000 |
| NOW()+0
TIMESTAMP
are converted to 2000-2069.
00-69
are converted to 1970-1999.
70-99
values that have two-digit years.
YEAR
[971]
and
MIN()
values:
DATETIME
[948]
CAST()
or
values to numeric form (for example, by adding
DATETIME
|
types, MySQL interprets dates specified with ambiguous year
and have it be interpreted as 2000, specify it as a
YEAR(4)
[971]
convert a
MAX()
847
type contains no time
DATE
type contains no date
TIME
'23:12:31'
'0000-00-00'
values, the time portion of
DATETIME
type by adding the time portion as
function to cause the comparison
inserted into
00
YEAR(4)
to a number. This means that a
YEAR
interpreted as a
or NULL.
results in

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents