Looking for a little assistance. I have Drupal 7 up and running with the View and Date module. I'm attempting to build a content type where the only additional fields other than Title and Body are, Post Date and Expire Date. Setting up the view is easy but I can't seem to figure out how to make the view only appear with values between Post Date and Expire Date. Does anyone have any experiance setting this up this type of view?
3 Answers
If you installed the Date module, you don't need to add two fields (Post and Expire). You can add a date field with start and end date.
Other than that, the rest is simple: Add two filters to the view.
The first filter will select the start date and show the fields that are less than or equal to now. (You can write that only if you select Enter a relative date.)
The second filter will select the expire date and show the fields that are greater than or equal to now.
If less than or equal to and greater than or equal to don't appear as options, make sure you enabled the Date Views module. (It is installed as part of the Date module.)
There is a module for that!
This Views filter provides the between date functionality you've been looking for by answering the question: "What events are on this date?" It displays all content (comparing start and end dates) occurring on a specified date.
Creating this functionality with standard Date filters requires two filters: start date less than or equal (<=) to the supplied date and end date greater than or equal (>=) to the supplied date. The problem is two filters means users must enter a date range, when technically selecting "September" is a range: September 1st to the 30th.
It compares two date fields with one supplied date. Effectively it is the opposite of the standard Date Views "between" operator, which compares one date field with two supplied dates.
Just a heads up about this: When I first started down this path, I was using the node published date (not date field). The sorting between didn't work as expected due to the extra time information. I wanted to sort by day only and didn't care about what time something was created during the day.
Long story short: make sure you use the date module and create date fields for this type of sorting.
Another conflict I found was with regards to date-popup. I was also using better exposed filters, which has a different version of jquery_ui calendar popup than date_views (another shortfall of not using the date module is there is no calendar popup). Anyway, make sure you use the default popup with date_views, because I had lots of issues with date formats getting wonky and not validating.