I'm not sure if this is a βclassicβ date range, for example. for the period of the current month, if it were
SELECT ... WHERE `date` >= '2011-12-01' AND `date` < '2012-01-01'
The idea is that time is a continuum and a period infinitely divisible. In other words, it is theoretically impossible to determine the last time granule of the current month. Is this one microsecond until midnight January 1? One nanosecond?
Well, in practice, it may be possible to determine the minimum time granule using the temporary data type in the DBMS of your choice. However, this changes the time model from a continuum to a series of discrete points in time, and you will need to do a lot of extra work to ensure that comparisons are made using the same time granules. The classic mistake is that the current month is defined as start_date = 2011-01-12 end_date = 2011-12-31
during the pellet in one day, then someone wonders why the value of DATETIME
2011-12-31 12:00:00
does not fall in the current month or, even worse, does not fall in any month!
In contrast, it is easy to determine the first time granule, which is not included in the current month, that is, January 1, in the granule in one day. This is referred to in the literature as a closed presentation or βsemi-openβ and is apparently most widely used.
In conclusion, if you cannot guarantee that temporal values ββof a pellet of less than one day can be effectively removed from your model (and I suggest you not do it!), Then use a closed view and avoid BETWEEN
to verify that the values ββfall over the period .
onedaywhen
source share