Letting the user select a date range, say:
Show me the notes from [ Aug 1 ] to [ Sep 1 ]
As usual, I expected this to include September 1 results. Especially when you consider that when I choose the same date for both ends, I obviously mean "from the beginning of the day to the end of the day":
Show me the entries from [ September 1 ] to [ September 1 ]
As a programmer, I think of date boundaries as a "zero-hour", i.e. "beginning of the day"; logically, the entries for September 1 are actually after "2010-09-01 00:00:00" (therefore, out of range).
For example, in SQL, the following condition would rule out everything:
SELECT * FROM entries WHERE created_at >= DATE('2010-09-01') AND created_at <= DATE('2010-09-01')
Obviously, you need to make adjustments from user input in SQL to increase the end date by 24 hours.
However, this only applies to timestamp or datetime columns. When the column is a date, then a direct comparison is performed and this setting should not be added.
In an MVC environment like Rails, where do you handle the logic for this input mismatch before submitting a request? If it is in the controller, it seems that it relies too much on knowing the internal fields of the model (date versus datetime), and if it were in the model, did the find_in_date_range method be understood to be inclusive or simply invoke daily errors?
Finally, my assumption is correct so that the user interface is included ranges? Is this always the case, or are there situations where a more stringent (exclusive) date limit is? For example, in my rake scripts, I use the END_DATE=2010-09-01 parameter to write to this date, which contradicts the user interface, but it makes sense to me: where do you draw this line?