Software engineer, data guy, Open Source enthusiast, New Hampshire resident, husband, father. Fan of guitars, hiking, photography, homebrewing, sarcasm.
Drupal 6: Passing date ranges into a view as arguments
At some point you might want to pass date ranges as arguments to a view. Unfortunately the built-in functionality of views does not allow you to use a date argument as a range. If you try to specify the date arguments by editing your view, the views module will automatically insert SQL to match the dates exactly, which will not work in this scenario. Assuming that you already have a view and a content type that has two fields for start and date ranges, you can add a hook_db_rewrite_sql() function to add your own SQL to the view’s query.
Now you can pass the date ranges in as arguments using the views_embed_view function:
Update 2011-02-14:
Seems that you actually don’t need to do a rewrite of the sql with complex code. You can do it like this:
Since views_embed_view is a wrapper around views_get_view(), this might work too: