Date and Time Functions
918
•
CONVERT_TZ(dt,from_tz,to_tz)
[918]
CONVERT_TZ()
[918]
converts a datetime value
dt
from the time zone given by
from_tz
to the
time zone given by
to_tz
and returns the resulting value. Time zones are specified as described in
Section 10.6, “MySQL Server Time Zone Support”
. This function returns
NULL
if the arguments are
invalid.
If the value falls out of the supported range of the
TIMESTAMP
type when converted from
from_tz
to UTC, no conversion occurs. The
TIMESTAMP
range is described in
Section 11.1.2, “Date and
Time Type Overview”
.
mysql>
SELECT CONVERT_TZ('2004-01-01 12:00:00','GMT','MET');
-> '2004-01-01 13:00:00'
mysql>
SELECT CONVERT_TZ('2004-01-01 12:00:00','+00:00','+10:00');
-> '2004-01-01 22:00:00'
Note
To use named time zones such as
'MET'
or
'Europe/Moscow'
, the time
zone tables must be properly set up. See
Section 10.6, “MySQL Server Time
Zone Support”
, for instructions.
If you intend to use
CONVERT_TZ()
[918]
while other tables are locked with
LOCK TABLES
, you
must also lock the
mysql.time_zone_name
table.
•
CURDATE()
[918]
Returns the current date as a value in
'YYYY-MM-DD'
or
YYYYMMDD
format, depending on whether
the function is used in a string or numeric context.
mysql>
SELECT CURDATE();
-> '2008-06-13'
mysql>
SELECT CURDATE() + 0;
-> 20080613
•
CURRENT_DATE
[918]
,
CURRENT_DATE()
[918]
CURRENT_DATE
[918]
and
CURRENT_DATE()
[918]
are synonyms for
CURDATE()
[918]
.
•
CURRENT_TIME
[918]
,
CURRENT_TIME()
[918]
CURRENT_TIME
[918]
and
CURRENT_TIME()
[918]
are synonyms for
CURTIME()
[918]
.
•
CURRENT_TIMESTAMP
[918]
,
CURRENT_TIMESTAMP()
[918]
CURRENT_TIMESTAMP
[918]
and
CURRENT_TIMESTAMP()
[918]
are synonyms for
NOW()
[926]
.
•
CURTIME()
[918]
Returns the current time as a value in
'HH:MM:SS'
or
HHMMSS.uuuuuu
format, depending on
whether the function is used in a string or numeric context. The value is expressed in the current time
zone.
mysql>
SELECT CURTIME();
-> '23:50:26'
mysql>
SELECT CURTIME() + 0;
-> 235026.000000
•
DATE(expr)
[918]
Extracts the date part of the date or datetime expression
expr
.
mysql>
SELECT DATE('2003-12-31 01:02:03');
-> '2003-12-31'
Summary of Contents for 5.0
Page 1: ...MySQL 5 0 Reference Manual ...
Page 18: ...xviii ...
Page 60: ...40 ...
Page 396: ...376 ...
Page 578: ...558 ...
Page 636: ...616 ...
Page 844: ...824 ...
Page 1234: ...1214 ...
Page 1427: ...MySQL Proxy Scripting 1407 ...
Page 1734: ...1714 ...
Page 1752: ...1732 ...
Page 1783: ...Configuring Connector ODBC 1763 ...
Page 1793: ...Connector ODBC Examples 1773 ...
Page 1839: ...Connector Net Installation 1819 2 You must choose the type of installation to perform ...
Page 2850: ...2830 ...
Page 2854: ...2834 ...
Page 2928: ...2908 ...
Page 3000: ...2980 ...
Page 3122: ...3102 ...
Page 3126: ...3106 ...
Page 3174: ...3154 ...
Page 3232: ...3212 ...