how can I filter a view by the date field

Events happening in the community are now at Drupal community events on www.drupal.org.
avior's picture

Hi There
I have been trying to filter view with the cck date field, and can't make it to work , i am missing something...

I have an defined event content type with a start date & end date
I have created an events view that i wish to filter as a start date with the logic :

  1. if no argument has been sent to the view than start_date >= now
  2. if a date parameter has been sent then start_date >= arg[0]

if have 3 filters , first 2 are published and term id , and another filter "start_date" "greater or equal to" and set the value to "now"

in the arguments i have set the code

if ($args[0]) {
    $view->filter[2]['value'] = $args[0];
}
$view->is_cacheable = 0;
return $args

do I need to convert the date to a date format ?
what is the date argument format ? ( in the date field i use dd/mm/yyyy)

I am using drupal 5 , cck 1.6-1, date field 1.8 & view 1.6

Thanks
Avior

Comments

I have manged to do this

avior's picture

Hi
I have manage to do this only by setting the start_date as an argument to the view
and set the argument code to

if (!$args[0]) {
     $args[0] = "@";
}
$view->is_cacheable = 0;
return $args;

@ - means starting from today

Facing similar problem. Any guidence?

Firoj's picture

Hello avior, I'm working for a newspaper site. i've a ckk field name "news published date". I want to filter the content by last published date. Is there any way?

Firoj

have a look here

avior's picture

Hi

As i was saying , i have set the views argument and used argument code to set the argument value by a page argument, something like this

$args[1] = arg(1);

have a look here http://groups.drupal.org/node/9770

hope this helps
Avior

Views Developers

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: