4

My issue is somewhat opposite of the common "List nodes within a date range".

So, I have an Event content type, with fields start_date and end_date. They show when the event starts, and when the event ends. Now I need to be able to select a date and fetch all events for which start_date < selected_date and end_date > selected_date.

The selected date should be an exposed filter to all users, or any other way that makes it possible to be fetcher from the URL.

Thanks in advance!

2 Answers 2

7

Have you tried adding an exposed filter in your view? I'm assuming you're using a view already, and I'm assuming you're using Drupal 7 (it's always helpful to specify that in the question, by the way :-)).

Add the date in question to your list of filters, check the box to expose it to users and use the 'is not between' option. Then you can either specify a hard coded date for the 'from' and 'to' or you can even use a relative date (second value type option) and specify something like '-30 minutes' and '+30 minutes' and it will re-calculate them based on the current time...

enter image description here

Hope this helps. Let us know if it works.

1
  • This is has option from current time. Is there any option with views for checking from current day. Not from current time.
    – purab
    Commented Aug 7, 2013 at 6:00
1

You may want to know that you can also use Views between dates filter module which was designed for this purpose.

You only need to install it and configure it and just select the two date fields and select its granullarity (in my opinion this is a problem since if you select year, month and date it wouldn't work if you typed only a year.

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.