Date and Time Functions
925
mysql>
SELECT HOUR('10:05:03');
-> 10
mysql>
SELECT HOUR('272:59:59');
-> 272
•
LAST_DAY(date)
[925]
Takes a date or datetime value and returns the corresponding value for the last day of the month.
Returns
NULL
if the argument is invalid.
mysql>
SELECT LAST_DAY('2003-02-05');
-> '2003-02-28'
mysql>
SELECT LAST_DAY('2004-02-05');
-> '2004-02-29'
mysql>
SELECT LAST_DAY('2004-01-01 01:01:01');
-> '2004-01-31'
mysql>
SELECT LAST_DAY('2003-03-32');
-> NULL
•
LOCALTIME
[925]
,
LOCALTIME()
[925]
LOCALTIME
[925]
and
LOCALTIME()
[925]
are synonyms for
NOW()
[926]
.
•
LOCALTIMESTAMP
[925]
,
LOCALTIMESTAMP()
[925]
LOCALTIMESTAMP
[925]
and
LOCALTIMESTAMP()
[925]
are synonyms for
NOW()
[926]
.
•
MAKEDATE(year,dayofyear)
[925]
Returns a date, given year and day-of-year values.
dayofyear
must be greater than 0 or the result
is
NULL
.
mysql>
SELECT MAKEDATE(2011,31), MAKEDATE(2011,32);
-> '2011-01-31', '2011-02-01'
mysql>
SELECT MAKEDATE(2011,365), MAKEDATE(2014,365);
-> '2011-12-31', '2014-12-31'
mysql>
SELECT MAKEDATE(2011,0);
-> NULL
•
MAKETIME(hour,minute,second)
[925]
Returns a time value calculated from the
hour
,
minute
, and
second
arguments.
mysql>
SELECT MAKETIME(12,15,30);
-> '12:15:30'
•
MICROSECOND(expr)
[925]
Returns the microseconds from the time or datetime expression
expr
as a number in the range from
0
to
999999
.
mysql>
SELECT MICROSECOND('12:00:00.123456');
-> 123456
mysql>
SELECT MICROSECOND('2009-12-31 23:59:59.000010');
-> 10
•
MINUTE(time)
[925]
Returns the minute for
time
, in the range
0
to
59
.
mysql>
SELECT MINUTE('2008-02-03 10:05:03');
-> 5
•
MONTH(date)
[925]
Returns the month for
date
, in the range
1
to
12
for January to December, or
0
for dates such as
'0000-00-00'
or
'2008-00-00'
that have a zero month part.
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 ...