DATE_SUB (NOW (), INTERVAL5MINUTE) and DATE_FORMAT (DATE_SUB (NOW (_ MySQL

Source: Internet
Author: User
DATE_SUB (NOW (), INTERVAL5MINUTE) and DATE_FORMAT (DATE_SUB (NOW (), INTERVAL5MINUTE), bitsCN.com

DATE_SUB (NOW (), INTERVAL 5 MINUTE) and 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. 030 s user 0m0. 005 s sys 0m0. 003 s [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. 602 s user 0m0. 008 s sys 0m0. 003 s DATE_SUB (NOW (), INTERVAL 5 MINUTE) DATE_FORMAT (DATE_SUB (NOW (), INTERVAL 5 MINUTE), '% Y-% m-% d % H: % M: % S ')

What about data inconsistency?

What are the differences between the two statements?

Intuition tells me that the format is incorrect, so I did the test myself.

Sure enough> The values are different,

Here, July can be compared with the> symbol after the month is converted into an ascii code.

In this case, the results will be different.

One is a purely numeric string, and the Middle month is in English. The difference is that the date of the English string is not good> or <这样的处理操作< p>

BitsCN.com

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.