1

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?

4

First of all if you have date module you do not need to add two fields "Post" and "Expire". You can add a date field with a start and an end date. Other than that the rest is simple. Go to your view and add two filters.

First filter will be your start date where the field is "less than or equal to" -> "now" (you can write that only if you select "enter a relative date" )

Second filter as you may have guessed will be your expire date field where the field is "is 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've enabled the Date Views module. (It is installed as part of the Date project.)

0

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.

0

There is a module for that!

Views between dates filter

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.

0

You should look into this documentation as well. It is very precise & very well explained. This worked for me.

Thanks to Mory's above documentation, I was able to find a solution to my scenario.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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