Skip Navigation

[Resolved] Views 1.8 Sort by Post Date how to set two BETWEEN full dates YYYY/MM/DD to YYYY

This support ticket is created 8 years, 5 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

This topic contains 3 replies, has 1 voice.

Last updated by nathanW-4 8 years, 5 months ago.



I've installed the new version of views which allows you to sort by post date. Which is great.

But I can't see a way to filter between two date ranges easily, I can filter between two YEARS but not Year, Month, Date.

One specific one that I need to do via url parameters is Financial year, which is June 31, to Jul 1 the following year. How can this be achieved with views?

URGENTLY need to figure this out.



Also, if this could be updated via the existing ajax setup that would be ideal [rather than url param]


Hmmm, you've managed to make a date filter without the most basic necessity of a feature!

Simply needs to be able to filter between two dates, but it doesn't seem that views can do this even with the new version, what a let down!

Simply need the same as custom fields have - filter between to fields yyyy mm dd and yyyy mm dd.


Solved this with a custom query and url parameters. Shame views couldn't do it should have been easy.

For anyone else here's my code - it accepts 2 url parameters wpv-from-date and wpv-to-date, with the following date formats: MM/DD/YYYY

They can be added to a views page url like so:


if($_GET["wpv-from-date"] && $_GET["wpv-to-date"]){
add_filter('wpv_filter_query', 'date_range', 99, 3 );

function date_range($query_args) {
    $fromdate = $_GET["wpv-from-date"];
    $todate = $_GET["wpv-to-date"];
    $query_args['date_query'][] = array(
          'after'         => $fromdate,
          'before'        => $todate
    return $query_args;