Should datepickers be inclusive or exclusive?

by Nathron   Last Updated May 15, 2019 10:16 AM

Does the chosen end date stop at 0:00 (exclusive) or 23:59:59 (inclusive)?

I have been changing datepickers in my company's codebase to be inclusive (assuming it was just a UX oversight by other devs), but it made me wonder whether it was just my preference more so than a convention.

Do users expect datepickers to be inclusive or exclusive, and what are the exceptions? Does the same hold true when choosing just month or year?

Answers 4

I'd say inclusive, simply because if I pick a date or date range I'm thinking about that specific time or range. If I wanted a time range between 2am and 3am I wouldn't want to put 01:59:59 - 03:00:01.

Whatever choice you make, make sure you are constant across your code base. Once you've established a standard in your project, breaking that, especially with picking dates like this, can cause a lot of confusion and problems.

November 16, 2016 02:08 AM

I think it depends a bit on the audience.

If I talk to my DBA, s/he wants me to be very explicit as to which I want.

However if I create a UI for the general public, the inclusive (IMHO) makes more sense to how "regular people" think.

E.g. If I asked a 100 users what they would expect if they picked this filter:

Show all events:
[_Oct_1,_2016_] to [_Oct_7,_2016_]

Most would expect any event on ANY of those 7 days to be included.

November 16, 2016 11:46 AM

It all depends on the audience.

If your application/code is exposed to normal people than go "exclusive". There are probably very few cases where the normal people will think "inclusive".

Example one: Let's meet at midnight today. To you that will mean 00:00 even if considering the technical side that will be tomorrow, right?

Example two: If I am interested in a payment I've made yesterday as a normal person yesterday means from 00:00 to 00:00 today considering that transaction was completed before 00:00 today.

Of course if the context says for the audience 23:59:59 is a completely different thing than 00:00 - you could consider "inclusive" in this case.

The bottom line is to realize how the users of your end app think and help them as much as possible - relevance and simplicity over anything else.

Bistrian IOSIP
Bistrian IOSIP
November 16, 2016 14:52 PM

Half open: start <= x < end

If you have two consecutive intervals, you want their intersection to be empty, and their union to include all the hits.

May 15, 2019 09:47 AM

Related Questions

Updated June 29, 2017 08:16 AM

Updated April 24, 2016 08:06 AM

Updated September 14, 2017 09:16 AM

Updated July 30, 2016 08:06 AM

Updated October 30, 2017 14:16 PM