MySQL DATEDIFF() 函数

SQL 教程 · 2019-03-04 13:29:32

定义和用法

DATEDIFF() 函数返回两个日期之间的天数。

语法

DATEDIFF(date1,date2)

date1 和 date2 参数是合法的日期或日期/时间表达式。

注释:只有值的日期部分参与计算。

实例

下面是 SELECT 语句:

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

结果如下所示:

DiffDate
1

实例

下面是 SELECT 语句:

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

结果如下所示:

DiffDate
-1

点击查看所有 SQL 教程 文章: https://www.codercto.com/courses/l/29.html

查看所有标签

Learning PHP, MySQL, and JavaScript

Learning PHP, MySQL, and JavaScript

Robin Nixon / O'Reilly Media / 2009-7-21 / USD 39.99

Learn how to create responsive, data-driven websites with PHP, MySQL, and JavaScript - whether or not you know how to program. This simple, streamlined guide explains how the powerful combination of P......一起来看看 《Learning PHP, MySQL, and JavaScript》 这本书的介绍吧!

Markdown 在线编辑器
Markdown 在线编辑器

Markdown 在线编辑器

HEX HSV 转换工具
HEX HSV 转换工具

HEX HSV 互换工具

HSV CMYK 转换工具
HSV CMYK 转换工具

HSV CMYK互换工具