Hello!

Is there a way to specify a date range for the fixed value of a contextual filter default?

I tried things like 2011:2012 or 2011,2012 but it only seems to interpret the first of the two years.

Comments

rdeboer’s picture

If it is NOT currently possible through the UI then a realisation of this feature can't be too far away, as I noticed when I got Views to output the query executes that it generates something like this for this case of a Fixed value of "201203". This is regardless of whether the "Start/End date range" radio box is selected:

...
WHERE (( (DATE_FORMAT(field_data_field_riks_date.field_riks_date_value, '%Y-%m') >= '2012-03' 
AND DATE_FORMAT(field_data_field_riks_date.field_riks_date_value, '%Y-%m') <= '2012-03') ))
...
rdeboer’s picture

Status: Active » Closed (works as designed)

Ok, so it is possible.
Found by trawling through the source code that the "to" separator is double-hyphen (--).
Example: 2012-03-25--2012-03-31.
Is this Views' best kept secret?

jamesTbaker’s picture

@RdeBoer, you're the awesomest! Thanks for the solution!

jamesTbaker’s picture

Issue summary: View changes

.

qasimzee’s picture

Issue summary: View changes

You sir made my day. Thanks

rdeboer’s picture

For more more flexible date and other ranges, see this module: http://drupal.org/project/contextual_range_filter

poiu’s picture

People from the future: make sure that "Date Views" (a Date submodule) is enabled or the double-hyphen thing won't work.