Create a view to list nodes.
- Expose post date filter use operator as "between"
- I am also using better expose filter to set the jquery UI popup for the date.

Now I want a list of all the posts on Dec 29, 2016.
a. If I select the dates as Dec 29, 2016 and Dec 29, 2016, it does not give any result.
b. If I select the dates as Dec 29, 2016 and Dec 30, 2016, it shows the post with post date Dec 29, 2016.

This might be confusing for the end user.

My proposed solution is to always append time component to date even if it is not sent via filter.
For eg: for the use case (a) dates are converted to Dec 29, 2016 00:00:00 and Dec 29, 2016 23:59:59. This will results in correct result.

Any feedback on this is appreciated.

CommentFileSizeAuthor
#5 view-filter_task.png53.05 KBpriyanka.tawde
#2 2839856.patch1.01 KBkurund
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

kurund created an issue. See original summary.

kurund’s picture

FileSize
1.01 KB
yogesh145’s picture

I have used "is greater than or equal to" and "is less than or equal to" clause instead of Between clause in exposed filter
and altered query using "views_query_alter" function like,

function module_views_query_alter(&$view, &$query) {

if($view->name == 'view_name')
{

$min1 = $view->exposed_input['created'];
$max1 = $view->exposed_input['created_1'];
if(!empty($min1) && !empty($max1)) {

$query->where[2]['conditions'][0]['field'] = "DATE_FORMAT(FROM_UNIXTIME(commerce_order.created), '%Y/%d/%m') >= (STR_TO_DATE('{$min1}', '%m/%d/%Y'))";
$query->where[2]['conditions'][1]['field'] = "DATE_FORMAT(FROM_UNIXTIME(commerce_order.created), '%Y/%d/%m') <=(STR_TO_DATE('{$max1}', '%m/%d/%Y'))";

}

}
}

This will results in correct result.

zalak.addweb’s picture

Issue tags: +views exposed filters
priyanka.tawde’s picture

FileSize
53.05 KB

Hi,

We have checked that issue. We have created view with content and check with exposed date condition as between for same date its giving proper result please check attachement

kurund’s picture

Are you including the time in the date filter? In my use case time is not included.