2

I am trying to query a MySQL database for all records for tomorrow (not the next 24 hours). All the dates are stored as a unixtimestamp.

Could I use the CURDATE() function in anyway?

Your help would be much appreciated!

avfc_error
  • 21
  • 1
  • 1
    Possible duplicate of [MySQL's now() +1 day](https://stackoverflow.com/questions/3887509/mysqls-now-1-day) – AlleXyS Jan 31 '18 at 21:42
  • Can we see sample data? You say "all the dates" are stored as a unix timestamp, which suggests that you are using the timestamp merely for precision to the day and not to the second. (E.g., suggests that all of tomorrow's records are timestamped 1517551200.) – pilcrow Feb 01 '18 at 15:11

1 Answers1

0

Select those records whose epoch timestamp is

BETWEEN UNIX_TIMESTAMP(CURDATE() + INTERVAL 1 DAY)
         AND
        UNIX_TIMESTAMP(CURDATE() + INTERVAL 2 DAY - INTERVAL 1 SECOND)

The beginning of tomorrow is one day beyond today, taken with precision to the second.

The end of tomorrow is one second less than two days beyond today, again taken with second precision.

While it is tempting simply to add 86,399 seconds to the beginning of tomorrow to find its end, some days have more seconds and some have fewer. Better to let date arithmetic functions compute the end.

pilcrow
  • 56,591
  • 13
  • 94
  • 135
  • No problem. If you like the answer and it works for you, let me ask you to upvote and accept... – pilcrow Feb 02 '18 at 16:52