I have a MySQL query in which I want to fetch all records from a particular year and then export and import it locally. I would have liked to bring it for the year only, but since there were so many records (when I wanted to import it, it wouldn't let me because of its size) I had to split it into two parts, in months (01 to 06 and 07 to 12).
The query I made in the first half of the year between months 01 to 06 was done well, the problem was with the other half (07 to 12). The Date data type is datetime . The query, which is very simple, I did it like this:
select * from `estadistica` where Fecha BETWEEN '2020-07-01' and '2020-12-31'
And in this case, I don't know why, it only brings me up to the 30th of the 12th month (12/30), that is, it rules out the 12/31. And it's not that there are no records, there are, because I did a common query and it shows data from day 31.
I have also tried this other query (putting HH:MM:SS):
select * from estadistica where Fecha BETWEEN '2020-07-01 00:00:00' and '2020-12-31 00:00:00'
and the same thing happens, it only brings me until December 30 .