I have a few thousand nodes with different dates as one of the fields. I am trying to create an exposed filter in views that allows the user to filter by day, month, or year.

For example, I would like someone to be able to enter "July" and get all the nodes associated with July, regardless of their day or year. I would also like users to be able to filter for "July 6" of any year or only "July 1973." Likewise, I would also like the user to have the ability of drilling right down to "July 6 1973" with the filter.

I have created a view with day granularity and an "equal to" operator. While this allows the user to select by day, month, and year ("July 6 1973"), any time only day, month, or year is put in, the form indicates that the other parts of the date need to be entered as well.

Does anyone have any suggestions?

2 Answers 2


I ended up creating a module that made three new fields - month, day, and year - and then processed the date field to populate these new fields. Then it was simply a matter of adding a view with exposed filters for month, day, and year.


Check if using the Views Date Format SQL module could be a solution for you. Here are some quotes about it (from its project page):

... allows to format date fields using SQL.

The core functionality is to remove the date formatting from render() and put it in query(). I.e. format date values using SQL's DATE_FORMAT rather than PHP's format_date. This is achieved by assigning a new default handler to node 'created' and 'changed' date fields. This handler extends and overrides views's build in views_handler_field_date.

The UI is completely unobtrusive, only a single checkbox "Use SQL to format dates" is added to the handler configuration popup.

Your question is not about creating charts in Drupal, but you may want to refer to this comment also for an example of how we typically use it within the Charts module.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.