Site Building

Create a View with Exposed Date Filters for Drupal 7

This page is archived

We're keeping this page up as a courtesy to folks who may need to refer to old instructions. We don't plan to update this page.

Sprout Video

In this chapter Michelle will walk us through using our new date field with Views to create a listing of our content showing the dates associated with them. We'll be listing our date content, with an exposed filter for selecting the date range, and we look at how to set relative dates to fill in the form's default values.

You'll need to the Views and Chaos Tools modules for this chapter. If you would like a refresher on using Views, you can watch our Intro to Views for Drupal 7 series.

Note: With an update in Date module (7.x-2.x), you can now change the format of the date in the exposed filter. It's not a completely smooth process, but here are some instructions for how to get this working.

1. Ensure that the following modules and their dependencies are enabled: Date, Date Views, Date Popup, Views UI.
2. Add a date field to a content type. Collect only the date (not the time -- uncheck hours, minutes, seconds). Create some content with a date.
3. Create a new view of fields filtered by the content type in which you added a date field.
4. Update the format as described in the video to table and add a label to the Title field.
5. Add the date field to fields. Choose the "short" format to display.
6. Add the date field to filters. Select "day" as granularity.
7. Expose the date filter. Configure it as described in the video.
8. The exposed date filter should show a long format in the text field, which is not what we want.
9. In a new tab, go to Configuration > Regional and Language > Date and time > Types
10. For the Date Type of "Short", select the 2nd option (10/21/2014 - 12:29). Save configuration.
11. Go back to your view and refresh the page. The date popup format should now be in the short format. It should now respect whatever format you choose for "Short" in the Date and Type settings.