Hey, I'm trying to find out how to do the following with views:

I want to create a list of news items and add an exposed filter based on node: created to filter on year and month, preferably in either a dropdown list or two sets of radiobuttons (one set for year, one set for month).

Right now, all I can get, is a textfield that takes in YYYY, but calculates the value based on 1/1/YYYY, meaning it won't return any results.

Is there some kind of module I need (and couldn't find), or is this just not possible?

Comments

nevets’s picture

If you have the Date module installed you can add a filter on "Date: Node".

I set

"Date form type" to "Select"

"Granularity" to "Month"

"Date year range" as desired

"Date field(s)" to "Node: Updated date"

"Operator" to "Is equal to"

And exposed to filter so users can choose.

lexa.mihu’s picture

i am using archive module and i want to filter results by year.
i.ve exposed date( node :post date ) and also date(node: update date) , set granularity to year , set default value 2011 and it's not working.

when i click on a month to see it;s results, it sends the wrong parameter to url... instead of date_filter[value][year]=2010 it sends date_filter[value]= 2011-01-01

tomotomo’s picture

Same problem. I created a date filter on my view, using a date CCK field. When I expose it and enter a value, no matter what date I select, the SQL says:

AND (DATE_FORMAT(node_node_data_field_somefield_node_data_field_anotherfield.field_anotherfield_value, '%Y-%m-%d') = '2011-01-01')

I did not select 2011-01-01.

My blog on Drupal/Vietnam: Saigonist
Twitter: @tomosaigon / @tomodrupal

tomotomo’s picture

Try upgrading to the latest dev of Views 2 (views-6.x-2.16). It seems to work better.

My blog on Drupal/Vietnam: Saigonist
Twitter: @tomosaigon / @tomodrupal

yixia’s picture

After update views with 6.x-2.16, still not fixed.
When I preview view, the sql still has a default value.(DATE_FORMAT(STR_TO_DATE(node_data_field_deceased_date.field_deceased_date_value, '%Y-%m-%dT%T'), '%Y-%m-%d') > '2011-01-01')

yixia’s picture

Found here if url parameter not set the date_filter, it force set a default value.
drupal\sites\all\modules\date\includes\date_api_filter_handler.inc line 52
if (empty($this->options['exposed']) || (isset($this->options['expose']['identifier']) && !isset($_GET[$this->options['expose']['identifier']]))) {
//$this->force_value = TRUE; //I just comment this line.
}