You can’t. WordPress does not support ranges of dates like that.
Ah ha. Cool, thanks for the response. Do you know of any other way to accomplish what I’m looking to do, or am I out of luck?
Mysql supports date math:
select date_sub(curdate(), interval 2 month);
The function curdate() returns the current date. When specifying the interval note that ‘month’ is not plural.
It should be possible to create a query that returns all posts for a given period. Unfortunately, you’ll have to get your hands dirty digging in the code.
Thanks for the reply Ogre. In the meantime I got dirty and figured out a way to do this.
In my query.php, I created a new if statement:
————
// Added by Scott for mulit-month searches
if ( $q[‘mult_month’] )
$where .= ” AND MONTH($wpdb->posts.post_date) BETWEEN ” . $q[‘monthnum1’] . ” AND ” .$q[‘monthnum2’] . “”;————
and inserted in above these lines in that file:
if ( ” !== $q[‘hour’] )
$where .= ” AND HOUR($wpdb->posts.post_date)='” . $q[‘hour’] . “‘”;
if ( ” !== $q[‘minute’] )
$where .= ” AND MINUTE($wpdb->posts.post_date)='” . $q[‘minute’] . “‘”;
Then, in my index.php, I call a script that determines the date range I want and runs the query_posts, the code looks like this:
query_posts(“year=$current_year&mult_month=1&monthnum2=$current_month&monthnum1=$last_month&order=DESC&posts_per_page=-1”);
The above references the mult_month variable to use the modified SELECT statement portion from query.php, then my monthnum1 and monthnum2 are the range for the date I need.
This will actually give me some possible trouble around December, so I might have to rework it….argh.
I will look into the function you refer to, thanks!