How to create advanced filter in list view with two date fields data with or operator
For example to list those records having date created last month or date modified last month
As advanced filter always uses and operator instead of or Operator
How to update the query to filter the records as per above filter
Please try the following steps:
Replace #MODULE# with your module
- Update custom/modules/#MODULE#/metadata/SearchFields.php (copy from modules folder if not present) with the following item
'search_date_entered_modified' => array(
'query_type' => 'default',
'db_field' => array('date_entered', 'date_modified'),
'is_date_field' => false,
),
- Update custom/modules/#MODULE#/metadata/searchdefs.php (copy from modules folder if not present) with the following item in βadvance_searchβ array.
'search_date_entered_modified'=>array(
'name'=>'search_date_entered_modified',
'default' => false,
'width' => '10%',
'label' => 'Date (Entered/Modified)',
'type' => 'date',
),
- Quick Repair & Rebuild

No itβs not working this way query is not getting formed correctly
Also the filter is not getting applied properly
Please try if the changing the definitions as follows works.
SearchFields.php
'search_date_entered_modified' => array(
'query_type' => 'format',
'operator' => 'subquery',
'subquery'=>
"select id from aos_products where aos_products.date_entered like '%{0}%' OR aos_products.date_modified like '%{0}%'",
'db_field' =>
array (
0 => 'id',
),
'is_date_field' => true,
),
searchdefs.php
'search_date_entered_modified'=>array(
'name'=>'search_date_entered_modified',
'default' => true,
'width' => '10%',
'label' => 'Date (Entered/Modified)',
'type' => 'date',
),
Thanks for the suggestion. Yes now query is getting formed but the query fails when we enable range search for this date field
I think we can write the range logic in the subquery SQL using between or <= ,>= etc. operators. Could you please try. Thanks.