Case Analysis of date query Boundary problem encountered by mysql between and
This article introduces an example analysis of the date query boundary problem encountered by mysql between and, the content is very detailed, interested friends can refer to, I hope it can be helpful to you.
The between and of mysql contains boundary values on both sides, but when querying the time and date, it is important to note
An example of For Example
Xx_nullx_values date time ax12017/1/12017/1/1 10:00:01ay22017/1/22017/1/2 12:00:00bx32017/1/32017/1/3 13:00:00az42017/1/42017/1/4 14:00:00
Query date time
It is found that although the date time between and contains January 3, the query result is not as good as January 3. This problem is due to the fact that this field is in date time format.
Date and time between'2017-01-01'and'2017-01-03' is equivalent to 'between 2017-01-01 00:00:00 and 2017-01-03 00 purse 00'
But we already know that 2017-01-03 00:00:00 equals 2017-01-02 23:59:59, so the time filter includes only 1 and 2, no 3-day data.
To solve this problem, you can convert the day-ahead time type into a date line date (date time) between '2017-01-01' and '2017-01-03'
This is the case analysis of the date query boundary problem encountered by mysql between and. I hope the above content can be helpful to you and learn more knowledge. If you think the article is good, you can share it for more people to see.