The name of my database time field is create_time
, and the type is TimeStamp
type
Now I want to get yesterday’s data~ For example, the time in the data is 2016-06-15 03:28:07
I used the following statement TO_DAYS(NOW()) - TO_DAYS(create_time) <= 1
The current computer time is 2016-06-15 13:45:12
The data is still displayed, but it should be impossible to find out... It stands to reason that the data on June 14, 2016 should be found...
Why is this sentence useless?
The name of my database time field is create_time
, and the type is TimeStamp
type
Now I want to get yesterday’s data~ For example, the time in the data is 2016-06-15 03:28:07
I used the following statement TO_DAYS(NOW()) - TO_DAYS(create_time) <= 1
The current computer time is 2016-06-15 13:45:12
The data is still displayed, but it should be impossible to find out... It stands to reason that the data on June 14, 2016 should be found...
Why is this sentence useless?
Why should it be less than or equal to 1? Wasn’t it equal to 1 yesterday?
The date format you save is a timestamp, just write it like this:
TO_DAYS(NOW())-TO_DAYS(FROM_UNIXTIME(create_time)) = 1