Get the App
SLTechnology News&Howtos  ›  Database  › 

How to obtain records in a certain period of time in mysql database

Shulou Source: shulou.com Published: 2022-05-31 18:47:29 09月30日 Update

This article mainly explains "how to obtain records in a certain period of time in mysql database". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "how the mysql database can obtain records within a certain period of time".

Generally speaking, when we record the data time in the mysql database, we will choose the datatime type, so that the time can be accurate to seconds. But one of the problems that comes with it is that when we want to get the data content over a certain period of time, there will be some trouble in time conversion. For example, if we want to get the content from March 2, 2002 to July 8, 2003, our first intuition is that we should write sql in the following form:

Select * from yourdb where sj > = '2002-3-2' and sj=to_days ('2002-3-2') and sj= TO_DAYS (a.beginDate)

And TO_DAYS (NOW ()) < TO_DAYS (a.endDate)

At this point, I believe you have a deeper understanding of "how the mysql database obtains records within a certain period of time". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Tags: Time data content database records that is advertising learning practical deeper accurate generally speaking between that is interest function practicality practice form I want Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information MySQL Apple MariaDB Huawei