Oracle 5.0 Reference Manual page 939

Table of Contents

Advertisement

DATEDIFF(expr1,expr2)
[919]
returns
DATEDIFF()
other.
and
expr1
expr2
are used in the calculation.
mysql>
SELECT DATEDIFF('2007-12-31 23:59:59','2007-12-30');
-> 1
mysql>
SELECT DATEDIFF('2010-11-30 23:59:59','2010-12-31');
-> -31
DATE_ADD(date,INTERVAL expr unit)
[922]
unit)
These functions perform date arithmetic. The
value.
is an expression specifying the interval value to be added or subtracted from the starting
expr
date.
is a string; it may start with a "-" for negative intervals.
expr
units in which the expression should be interpreted.
The
keyword and the
INTERVAL
The following table shows the expected form of the
Value
unit
MICROSECOND
SECOND
MINUTE
HOUR
DAY
WEEK
MONTH
QUARTER
YEAR
SECOND_MICROSECOND
MINUTE_MICROSECOND
MINUTE_SECOND
HOUR_MICROSECOND
HOUR_SECOND
HOUR_MINUTE
DAY_MICROSECOND
DAY_SECOND
DAY_MINUTE
DAY_HOUR
YEAR_MONTH
The values
QUARTER
The return value depends on the arguments:
if the first argument is a
DATETIME
and the
DATE
unit
Date and Time Functions
[919]
expressed as a value in days from one date to the
expr1
expr2
are date or date-and-time expressions. Only the date parts of the values
specifier are not case sensitive.
unit
and
are available beginning with MySQL 5.0.0.
WEEK
DATETIME
value uses HOURS, MINUTES, or SECONDS.
919
[919],
DATE_SUB(date,INTERVAL expr
argument specifies the starting date or datetime
date
unit
argument for each
expr
Expected
Format
expr
MICROSECONDS
SECONDS
MINUTES
HOURS
DAYS
WEEKS
MONTHS
QUARTERS
YEARS
'SECONDS.MICROSECONDS'
'MINUTES:SECONDS.MICROSECONDS'
'MINUTES:SECONDS'
'HOURS:MINUTES:SECONDS.MICROSECONDS'
'HOURS:MINUTES:SECONDS'
'HOURS:MINUTES'
'DAYS
HOURS:MINUTES:SECONDS.MICROSECONDS'
'DAYS HOURS:MINUTES:SECONDS'
'DAYS HOURS:MINUTES'
'DAYS HOURS'
'YEARS-MONTHS'
(or TIMESTAMP) value, or if the first argument is a
is a keyword indicating the
value.
unit

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents