0

how can I select in MariaDB between two dates (in this case between two minutes)? I mean I want to select between from now() +5 minutes and now() + 30 minutes. I tried with this query but no luck.

SELECT req_id FROM info WHERE date(sent_date) BETWEEN (NOW() - INTERVAL 5 MINUTE) AND date(sent_date) < (NOW() - INTERVAL 30 MINUTE)

Thank you so much for helping. BTW, I tried to search answer to my question in stackoverflow but I don't found.

kviktor1230
  • 101
  • 7
  • What is the data type f sent_date? Should the dates be the other way around > -30 and <-5? – Nathan_Sav Jan 07 '22 at 09:32
  • Does this answer your question? [adding 30 minutes to datetime php/mysql](https://stackoverflow.com/questions/1436827/adding-30-minutes-to-datetime-php-mysql) – steven7mwesigwa Jan 07 '22 at 09:40

1 Answers1

1

The syntax of your WHERE clause is off. Use this version:

SELECT req_id
FROM info
WHERE sent_date BETWEEN NOW() - INTERVAL 5 MINUTE AND NOW() - INTERVAL 30 MINUTE;
Tim Biegeleisen
  • 502,043
  • 27
  • 286
  • 360