Answer the question
In order to leave comments, you need to log in
Why does SELECT date( "2014-01-01" ) - date( "2013-12-31" ) return 8870?
Why does a query in mysql SELECT date( "2014-01-01" ) - date( "2013-12-31" ) return 8870 ?
MySQL version 5.1.66.
OS: FreeBSD 8.2-RELEASE
The date on the server is set correctly.
Answer the question
In order to leave comments, you need to log in
And what did you want to do by calling the DATE() function for dates that no longer have time? In fact, you have the difference of the strings "2014-01-01" and "2013-12-31", which are converted to the numbers 20140101 and 20131231, the difference of which is 8870.
To get the number of days between two dates, you can use the DATEDIFF function () :SELECT DATEDIFF('2014-01-01','2013-12-31');
no, I had to select records older than 60 days.
did like this:
SELECT TO_DAYS(now()) - TO_DAYS(timefrom)) > 60;
those. the to_days function operates on dates, and the date function operates on numbers.
thank you very much.
I don’t know why, but in terms of processing time, the option:
(TO_DAYS( now( ) ) - TO_DAYS( timefrom )) < 60
and the option:
DATE_SUB( CURDATE( ) , INTERVAL 60 DAY ) < timefrom
are exactly the same, although the first option performs much more calculations .
while the table has ~1,089,909 rows
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question