Some examples from the JDK:
A related issue is specific to date values. It's common to have a date range specified using dates only (with no time portion), while the underlying data actually includes both a date and a time. This can easily lead to off-by-one errors.
For example, taking the following expression:
2010-01-01 <= x <= 2010-01-31then the following is true:
|Date x||In Range?|
|2010-01-31 00:00:00||Y (usually)|
(The caveat for 2010-01-31 00:00:00 is made since it will depend on the details of how the comparison is made by the class which models the date/time - usually, it will be within the range.)
The above table shows that times after 2010-01-31 00:00:00 are excluded from the range. This is usually not desirable. In this case, you need to alter the comparison slighty to:
2010-01-01 <= x < (2010-01-31 + 1 day)
Again, this uses the include-from, exclude-to style mentioned above.