WHERE DateAdd BETWEEN STR_TO_DATE ('2010-05-05','%Y-%m-%d') AND STR_TO_DATE ('2010-05-07','%Y-%m-%d')" 

Displays only records 2010-05-05 and 2010-05-06, and 2010-05-07 - no , although this record is there, and so with any date, you need to add +1 at the end of the day, so that the sample works correctly.

What could it be?

  • one
    What type of data is used to store the date? Why do you use STR_TO_DATE? - Opalosolo
  • I insert a date there through PHP, I pass the String information to the date to select between dates. - Man
  • one
    @Yura Suchko, If you are given a comprehensive answer, mark it as correct (click on the check mark next to the selected answer). - Deleted

1 answer 1

And so you tried?

 WHERE DateAdd BETWEEN STR_TO_DATE ('2010-05-05 00:00:00','%Y-%m-%d %H:%i:%s') AND STR_TO_DATE ('2010-05-07 00:00:00','%Y-%m-%d %H:%i:%s')" 
  • the same result. - Man
  • one
    @Yura Suchko, if you have a stored type of timestamp , then you should take into account that it also stores time in itself. Therefore, the second part should go as the end of the day "2010-05-07 23:59:59" (and you have the very beginning, midnight "2010-05-07 00:00:00"). - Alex Krass
  • one
    oops confused, end of the day if you put: WHERE DateAdd BETWEEN STR_TO_DATE ('2010-05-05 00:00:00', '% Y-% m-% d% H:% i:% s') AND STR_TO_DATE (' 2010-05-07 23:59:59 ','% Y-% m-% d% H:% i:% s') " - evz
  • Exactly, thanks. - Man