Home > Database > Mysql Tutorial > mysql时间的操作sql语句_MySQL

mysql时间的操作sql语句_MySQL

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-01 13:34:43
Original
1047 people have browsed it

bitsCN.com

mysql时间的操作sql语句

 

select * from mytest where (select DATEDIFF(now(),current)=0) ;//今天的数据

SELECT OrderId,DATE_ADD(OrderDate,INTERVAL 2 DAY) AS OrderPayDate

FROM Orders

 

向 "OrderDate" 添加 2 天 即结果为

2008-12-31 16:25:46.635

 

SELECT OrderId,DATE_SUB(OrderDate,INTERVAL 2 DAY) AS OrderPayDate

FROM Orders

从 "OrderDate" 减去 2 天

结果:2008-12-27 16:25:46.635

 

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

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

 

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

 

SELECT DATEDIFF('2008-12-30','2008-12-29') AS DiffDate 结果1

 

SELECT DATEDIFF('2008-12-29','2008-12-30') AS DiffDate 结果-1

 

bitsCN.com
Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
How to get current date in JavaScript?
From 1970-01-01 08:00:00
0
0
0
datetime - How to get current time in Python
From 1970-01-01 08:00:00
0
0
0
How does a Vue file get the current instance?
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template