Oracle 5.0 Reference Manual page 951

Table of Contents

Advertisement

was changed. For dates before 1582 (and possibly a later year in other locales), results from this
function are not reliable. See
Remember that MySQL converts two-digit year values in dates to four-digit form using the rules in
Section 11.1.5, "Date and Time
as identical dates:
mysql>
SELECT TO_DAYS('2008-10-07'), TO_DAYS('08-10-07');
-> 733687, 733687
In MySQL, the zero date is defined as '0000-00-00', even though this date is itself considered
invalid. This means that, for
values shown here:
mysql>
SELECT TO_DAYS('0000-00-00');
+-----------------------+
| to_days('0000-00-00') |
+-----------------------+
|
+-----------------------+
1 row in set, 1 warning (0.00 sec)
mysql>
SHOW WARNINGS;
+---------+------+----------------------------------------+
| Level
| Code | Message
+---------+------+----------------------------------------+
| Warning | 1292 | Incorrect datetime value: '0000-00-00' |
+---------+------+----------------------------------------+
1 row in set (0.00 sec)
mysql>
SELECT TO_DAYS('0000-01-01');
+-----------------------+
| to_days('0000-01-01') |
+-----------------------+
|
+-----------------------+
1 row in set (0.00 sec)
This is true whether or not the
MySQL 5.0.2 and later) is enabled.
UNIX_TIMESTAMP()
If called with no argument, returns a Unix timestamp (seconds since
UTC) as an unsigned integer. If
returns the value of the argument as seconds since
a
string, a
DATE
DATETIME
The server interprets
in UTC. Clients can set their time zone as described in
Support".
mysql>
SELECT UNIX_TIMESTAMP();
-> 1196440210
mysql>
SELECT UNIX_TIMESTAMP('2007-11-30 10:30:19');
-> 1196440219
When
UNIX_TIMESTAMP()
internal timestamp value directly, with no implicit "string-to-Unix-timestamp" conversion. If you pass
an out-of-range date to
Note: If you use
UNIX_TIMESTAMP()
values and Unix timestamp values, the conversion is lossy because the mapping is
TIMESTAMP
not one-to-one in both directions. For example, due to conventions for local time zone changes, it
is possible for two
UNIX_TIMESTAMP()
Date and Time Functions
Section 12.8, "What Calendar Is Used By
Types". For example,
'0000-00-00'
NULL |
1 |
ALLOW_INVALID_DATES
[931],
UNIX_TIMESTAMP(date)
UNIX_TIMESTAMP()
string, a TIMESTAMP, or a number in the format
as a value in the current time zone and converts it to an internal value
date
[931]
is used on a
UNIX_TIMESTAMP()
[931]
[931]
931
'2008-10-07'
and '0000-01-01',
TO_DAYS()
|
[535]
SQL server mode (available in
[931]
[931]
is called with a
'1970-01-01 00:00:00'
Section 10.6, "MySQL Server Time Zone
column, the function returns the
TIMESTAMP
[931], it returns 0.
and
FROM_UNIXTIME()
to map two
TIMESTAMP
MySQL?", for details.
and
are seen
'08-10-07'
[930]
returns the
'1970-01-01 00:00:00'
argument, it
date
UTC.
date
or YYYYMMDD.
YYMMDD
[923]
to convert between
values to the same Unix
may be

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents