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 definitely not correct, so I did a test in person. Actually, the values after the test are different. In this case, July can only be compared with the symbol after the month is changed to ascii code, the result is a pure numeric string and a month in the middle is in English. The difference is that the date of the English string is not good> or <such a processing operation