Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Case Analysis of date query Boundary problem encountered by mysql between and

2025-04-11 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report