A more user-friendly date-based search


Recently in one of my freelance projects, the client needed a feature that allows them to search the database for records with a date between two specific dates.

Rather than opting for the typical three text fields + a date selector, I added a little trick to make it better…

Flaw one

Most of the time when inserting dates, you will see three text boxes: one for the day, another for the month, and a third for the year.

While this works okay, it’s often faster to just type the date in a single box, rather than having to tab through the separate boxes. But with a single textbox approach, you have to keep in mind that users may not enter the date in the correct format – for example, in the US, dates are in MM/DD/YYYY format, and in Finland DD.MM.YYYY – it could also be a less skilled user who just inserts something completely wrong.

However, since this project was being built for a client to replace their old system, and all the users of the system would know what kind of dates the system allows, the above thing could be safely ignored.

So I went with a single textbox. Or actually, two textboxes, since the search would function based on a starting date and an ending date, and return all items which are in between those two dates.

Flaw two

Another little issue with your typical date searches is that you always have to input the full date. If I want to find all records for the year 2008, why do I need to insert the day and the month too? Wouldn’t it be enough if I could just insert 2008 into the “from” box and 2009 to the “to” box?

So instead of requiring a full date, the system allows you to insert partial dates – you can insert just the year, just the month and the year, or a full date including the day.

In the end

With a little effort on the programmer’s end, the date searching feature is much nicer to use.

One additional benefit of using a single textbox is that you can easily copy-paste dates into it.

Since the search is a commonly used feature of the system, small things like this can make someone’s job a little easier. And isn’t that all what information systems are about, making a job easier?