0

Suppose the date today is: 2019-14-01

and I have a table that is:

________________________________
id    |    name    |    due_date
1     |   test_1   |  2019-17-01
2     |   test_2   |  2019-17-01
3     |   test_3   |  2019-16-01
________________________________

how do I get all of the rows with due_date 3 days from now in mysql

Daniel
  • 205
  • 2
  • 12
  • Possible duplicate of [Select records from NOW() -1 Day](https://stackoverflow.com/questions/8544438/select-records-from-now-1-day) or https://stackoverflow.com/questions/1713056/mysql-select-last-few-days or really any link that pops up when you type in your question's title and "mysql". – JNevill Jan 14 '19 at 15:46

1 Answers1

1
SELECT * FROM TABLE WHERE due_date = DATE_FORMAT(NOW() + INTERVAL 3 DAY , "%Y-%m-%d")
Daniel
  • 205
  • 2
  • 12
Ass3mbler
  • 3,855
  • 2
  • 20
  • 18
  • Just want to ask, now() returns time and date and in my column it only returns a date. I am having problems to get exactly the date. Something like: due_date = now() + 3 days. So when the scripts runs tomorrow, it wouldn't get qualified to have the due_date – Daniel Jan 14 '19 at 15:49
  • I just fixed this, while you was sending your message :) – Ass3mbler Jan 14 '19 at 15:49
  • 2
    Besides @Daniel `DATE_ADD(DATE_FORMAT(NOW(), "%Y-%m-%d"), INTERVAL 3 DAY)` can be written more simple like `NOW() + INTERVAL 3 DAYS` – Raymond Nijland Jan 14 '19 at 15:52