Home > other >  SQL SELECT WHERE datetime is between NOW() interval
SQL SELECT WHERE datetime is between NOW() interval

Time:01-08

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.

CodePudding user response:

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;
  •  Tags:  
  • Related