Come together with the global Drupal community in Rotterdam, 28 Sept – 1 Oct 2026. Sessions, contribution, connection, and Early Bird savings until 8 June.
so i created a cck field with option from date/to date. The view i want is a list of nodes who have today's date in between the cck fromdate/to date. How do i do that with the date module? Is it possible to refer to the 2 fields inside Views?
I needed to filter nodes with a from-to date field where 'now' is between the from-to interval. The view should show only nodes that should be published during a certain time frame.
Essentially, you still need to seperate view filters to make this one work. Trying this with one filter didn't work for me.
Before you start: Make sure your content type has a CCK date field has a 'datestamp' type with from/to subfields
Make a filter for the the From field:
1. Add a new filter for the date:date field. You need to select date:date (node).
2. Check the content:YOURFIELD - from date box.
3. Method should be set to AND
4. Now you can configure the newly created filter. Operator should be 'less then or equal to' and set the value in the 'date default' (under relative date) to 'now' (without quotes)
Now make a new filter for the To field
1. Add a new filter for the date:date field. You need to select date:date (node).
2. Check the content:YOURFIELD - to date box.
3. Method should be set to AND
4. Now you can configure the newly created filter. Operator should be 'Is greater then or equal to' and set the value in the 'date default' (under relative date) to 'now' (without quotes)
Save your query and run it through 'preview'. Should work now.
If you'd check the SQL query this combination of filters generate, you should see something along the lines of ... WHERE field_pub_value <= NOW() AND field_pub_value2 >= NOW() ...
Of course, this would be much cleaner if the WHERE clause would use the ... BETWEEN X AND Y ... statement instead.
Comments
Comment #1
mediamash commentedso i created a cck field with option from date/to date. The view i want is a list of nodes who have today's date in between the cck fromdate/to date. How do i do that with the date module? Is it possible to refer to the 2 fields inside Views?
Comment #2
mediamash commentedall dates are different in each node
i just want a list of nodes which date range (from/to cck) includes today/now
Comment #3
netsensei commentedTook me some time to figure this one out.
I needed to filter nodes with a from-to date field where 'now' is between the from-to interval. The view should show only nodes that should be published during a certain time frame.
Essentially, you still need to seperate view filters to make this one work. Trying this with one filter didn't work for me.
Before you start: Make sure your content type has a CCK date field has a 'datestamp' type with from/to subfields
Make a filter for the the From field:
1. Add a new filter for the date:date field. You need to select date:date (node).
2. Check the content:YOURFIELD - from date box.
3. Method should be set to AND
4. Now you can configure the newly created filter. Operator should be 'less then or equal to' and set the value in the 'date default' (under relative date) to 'now' (without quotes)
Now make a new filter for the To field
1. Add a new filter for the date:date field. You need to select date:date (node).
2. Check the content:YOURFIELD - to date box.
3. Method should be set to AND
4. Now you can configure the newly created filter. Operator should be 'Is greater then or equal to' and set the value in the 'date default' (under relative date) to 'now' (without quotes)
Save your query and run it through 'preview'. Should work now.
If you'd check the SQL query this combination of filters generate, you should see something along the lines of
... WHERE field_pub_value <= NOW() AND field_pub_value2 >= NOW() ...Of course, this would be much cleaner if the WHERE clause would use the ... BETWEEN X AND Y ... statement instead.
Comment #4
mediamash commentedindeed, i figured this out a few days ago. Thanks for writing this out, great for documentation!
Comment #5
arlinsandbulte commentedComment #7
daveparrish commentedWhy is it that the 'datestamp' type is required?
Comment #8
Jo_ commentedsubscribe
Comment #9
drupal92037 commentedThanks netsensei! I spent hours trying to figure how to do this -- I kept selecting Content as a filter instead of Date:Date.
Comment #10
stevebeck commentedYep a winner for me. Thanks for posting :)