Home > Database > Mysql Tutorial > DATE_SUB(NOW(),INTERVAL 5 MINUTE)与DATE_FORMAT(DATE_SUB(NOW(_MySQL

DATE_SUB(NOW(),INTERVAL 5 MINUTE)与DATE_FORMAT(DATE_SUB(NOW(_MySQL

WBOY
Release: 2016-06-01 13:31:51
Original
1573 people have browsed it

bitsCN.com

DATE_SUB(NOW(),INTERVAL 5 MINUTE)与DATE_FORMAT(DATE_SUB(NOW(),INTERVAL 5 MINUTE),'%Y-%m-%d %H:%M:%S')[sql] [root@CactiEZ ~]# time mysql -h 172.22.10.32 -ucacti -P3316 -pcacti -e "select count(*) from order.tbl_tieyou_order where order_time > DATE_SUB(NOW(),INTERVAL 5 MINUTE);" -N  +-----+  | 112 |  +-----+    real 0m0.030s  user 0m0.005s  sys 0m0.003s  [root@CactiEZ ~]# time mysql -h 172.22.10.32 -ucacti -P3316 -pcacti -e "select count(*) from order.tbl_tieyou_order where order_time > DATE_FORMAT(DATE_SUB(NOW(),INTERVAL 5 MINUTE),'%Y-%m-%d %H:%M:%S'); -N"  +----------+  | count(*) |  +----------+  |      365 |  +----------+  real 0m1.602s  user 0m0.008s  sys 0m0.003s    DATE_SUB(NOW(),INTERVAL 5 MINUTE)  DATE_FORMAT(DATE_SUB(NOW(),INTERVAL 5 MINUTE),'%Y-%m-%d %H:%M:%S')  
Copy after login

 

数据不一致呢?  

 

这2个语句有什么区别?

直觉告诉我肯定是格式不对的缘故,于是亲自做了测试

 

DATE_SUB(NOW(),INTERVAL 5 MINUTE)与DATE_FORMAT(DATE_SUB(NOW(_MySQL

 

果然〉后面的值不一样了,

其中july这个月份变成ascii码之后才能再用>符号进行比较

这样子的话,结果就会不同

 

一个是纯粹的数字字符串,一个中间的月份是英文的,差别在这里,英文字符串的日期不好做>或者

 

bitsCN.com
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