花美男为中国互联网事业而奋斗

MySQL DATEDIFF() Function

来源:未知 阅读(0)次 评论(0)

Definition and Usage

The DATEDIFF() function returns the time between two dates.

Syntax

DATEDIFF(date1,date2)

Where date1 and date2 are valid date or date/time expressions.

Note: Only the date parts of the values are used in the calculation.


Example

The following SELECT statement:

SELECT DATEDIFF('2014-11-30','2014-11-29') AS DiffDate

will result in this:

DiffDate
1

Example

The following SELECT statement:

SELECT DATEDIFF('2014-11-29','2014-11-30') AS DiffDate

will result in this:

DiffDate
-1


标签:
上一篇:MySQL Date Functions 下一篇:MySQL FROM_UNIXTIME() function

相关推荐