0

I am using MariaBD and am trying to filter entries with todays date and tomorrows date.

I have managed to filter todays date using

SELECT *, 
       DateTime AS Time 
FROM table
where status = 'Pending' 
and DateTime like concat(CURDATE(),'%') 
order by DateTime

I am struggling to add in entries with tomorrows date as well. Probably very easy but noting I am trying is working

I am using MariaDB

1 Answer 1

0

Try the following where clause:

  SELECT ... WHERE DATE(MyDateField) BETWEEN CURRENT_DATE AND ADDDATE(CURRENT_DATE, 1);
3
  • WHERE MyDateField >= CURRENT_DATE AND MyDateField < ADDDATE(CURRENT_DATE, 2) would be much more efficient. Oct 8, 2022 at 18:55
  • Are you sure? The documentation mentions no difference.
    – M. Behrens
    Oct 9, 2022 at 23:18
  • The function/conversion DATE(MyDateField) would prevent the use of any index on MyDateField. Oct 10, 2022 at 0:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.