Oracle 5.0 Reference Manual page 950

Table of Contents

Advertisement

mysql>
SELECT TIMESTAMPADD(MINUTE,1,'2003-01-02');
-> '2003-01-02 00:01:00'
mysql>
SELECT TIMESTAMPADD(WEEK,1,'2003-01-02');
-> '2003-01-09'
[929]
TIMESTAMPADD()
TIMESTAMPDIFF(unit,datetime_expr1,datetime_expr2)
Returns
datetime_expr2
are date or datetime expressions. One expression may be a date and the other a datetime; a date
value is treated as a datetime having the time part
result (an integer) is given by the
listed in the description of the
mysql>
SELECT TIMESTAMPDIFF(MONTH,'2003-02-01','2003-05-01');
-> 3
mysql>
SELECT TIMESTAMPDIFF(YEAR,'2002-05-01','2001-01-01');
-> -1
mysql>
SELECT TIMESTAMPDIFF(MINUTE,'2003-02-01','2003-05-01 12:05:55');
-> 128885
TIMESTAMPDIFF()
Note
The order of the date or datetime arguments for this function is the opposite
of that used with the
arguments.
TIME_FORMAT(time,format)
This is used like the
specifiers only for hours, minutes, seconds, and microseconds. Other specifiers produce a
value or 0.
If the
value contains an hour part that is greater than 23, the
time
produce a value larger than the usual range of 0..23. The other hour format specifiers produce the
hour value modulo 12.
mysql>
SELECT TIME_FORMAT('100:00:00', '%H %k %h %I %l');
-> '100 100 04 04 4'
TIME_TO_SEC(time)
Returns the
argument, converted to seconds.
time
mysql>
SELECT TIME_TO_SEC('22:23:00');
-> 80580
mysql>
SELECT TIME_TO_SEC('00:39:38');
-> 2378
[930]
TO_DAYS(date)
Given a date date, returns a day number (the number of days since year 0).
mysql>
SELECT TO_DAYS(950501);
-> 728779
mysql>
SELECT TO_DAYS('2007-10-07');
-> 733321
[930]
is not intended for use with values that precede the advent of the Gregorian
TO_DAYS()
calendar (1582), because it does not take into account the days that were lost when the calendar
Date and Time Functions
is available as of MySQL 5.0.0.
– datetime_expr1, where
argument. The legal values for
unit
TIMESTAMPADD()
[930]
is available as of MySQL 5.0.0.
TIMESTAMP()
[930]
[921]
DATE_FORMAT()
[930]
930
datetime_expr1
where necessary. The unit for the
'00:00:00'
[929]
function.
[929]
function when invoked with 2
function, but the
format
[930]
and
datetime_expr2
are the same as those
unit
string may contain format
and
hour format specifiers
%H
%k
NULL

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents