Home > Backend Development > PHP Tutorial > mysql 查询当前日期与字段日期 相差的天数

mysql 查询当前日期与字段日期 相差的天数

WBOY
Release: 2016-06-06 20:29:32
Original
1535 people have browsed it

订单表里面的订单 每隔30天 支付一次利息, 我想要获取今天支付利息的订单,订单创建日期都不一样,所以需要计算 (今天日期与订单创建日期之间的天数/30天) 取值

<code>select now(),created_at, DATEDIFF(now(),'created_at') as daydiff  from order</code>
Copy after login
Copy after login

返回的 daydiff 都是空的

回复内容:

订单表里面的订单 每隔30天 支付一次利息, 我想要获取今天支付利息的订单,订单创建日期都不一样,所以需要计算 (今天日期与订单创建日期之间的天数/30天) 取值

<code>select now(),created_at, DATEDIFF(now(),'created_at') as daydiff  from order</code>
Copy after login
Copy after login

返回的 daydiff 都是空的

created_at 不要引号

如果create_at是字段,不是特定日期的话,貌似只能放到where里去做筛选。

Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template