Skip Navigation

[Closed] Parametric Search – By year range (2 numeric fields)

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.

Tagged: 

This topic contains 12 replies, has 2 voices.

Last updated by Minesh 6 years, 4 months ago.

Assigned support staff: Minesh.

Author
Posts
#295733

How can we use parametric search to filter 2 numeric fields (year).

We have list of employees with a start year and end year. We want to list all employees that worked ex.: from 2002 to 2012.

We have try the Between condition but it not seem to work.

Is there a simple solution?

Thanks

#296018

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

You should use the filter "wpv_filter_query" in order to filter your query data. Please link as given under for more reference:
=> https://toolset.com/documentation/user-guides/views-filters/wpv_filter_query/

#298046

we tried to use a filter, unfortunatly we get 0 result every time we lauch a search using date.
Here the filter we created :

add_filter('wpv_filter_query', 'search_between_numeric_func', 90, 2);
function search_between_numeric_func($query, $setting) {
    if($setting['view_id'] == 19)
    {
        if(isset($_GET['date-de-debut1']) && !empty($_GET['date-de-debut1']) && isset($_GET['legue-date-de-fin1']) && !empty($_GET['legue-date-de-fin1']))
        {
                $query['meta_query'] = array(
									array(
                    'key'   => 'legue-date-de-debut-1',
                    'value' =>  array($_GET['legue-date-de-debut1'], $_GET['legue-date-de-fin1']),
				            'compare' => 'BETWEEN',
										'type'=> 'numeric')
							);
        }
    }
    return $query;
}
#298248

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

As I believe as WP documentation says:
"The 'type' DATE works with the 'compare' value BETWEEN only if the date is stored at the format YYYY-MM-DD and tested with this format"

Please look here:
=> https://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters

Could you please send me a link where I can see your issue in action as well as steps to reproduce your issue, few screenshots will be helpful.

Kindly send me debug information as well that will help us to debug your issue.

#298363

can i get your email so i can send your the url and the user/password needed to view the site.

#298401

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I've set next reply as private that means only supporters will be able to see this information, it will not be publicly available.

#299117

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

1)
Unfortunately your wp-admin access details are not working at this end, could you please check it and send us correct wp-admin access details.

2)
Please send me a link where I can see your issue in action.

I have set next reply as private.

#299648

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I checked in your database and I see that you are using two similar fields "wpcf-legue-date-de-debut1" and "wpcf-legue-date-de-debut" as well as wpcf-legue-date-de-fin1 and "wpcf-legue-date-de-fin".

I would like to know which field you want to use as "wpcf-legue-date-de-debut1" seems to store timestamp and "wpcf-legue-date-de-debut-1" is storing only year [ For ex. 2007 ].

Also, I can see that on this link you are using date picker: hidden link

If you want to search based on custom fields, I think there is no need for "wpv_filter_query", please refer to the following documentation that may help you:
=> https://toolset.com/documentation/user-guides/filtering-views-by-custom-fields/
=> https://toolset.com/documentation/user-guides/date-filters/

#300060

We are using legue-date-de-debut1.
we are trying to compare two time range to see if they overlap each other.

#300342

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Please allow me to consult with our developers and I will get in touch with you as soon as possible as soon as I know more.

#301323

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I have reported your issue to our next level support. Please be patient, wait for a reply from them and they will get in touch with you as soon as possible.

#302506

We are trying to take the value from legue-date-de-debut1 and legue-date-de-fin1 and the value entered in the parametric search to generate two date range. and check if those range overlap each other.

Can we get a time estimate if this is possible to do?

#306343

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Please accept our apologies for late reply. Our developer has check your issue and when we select two dates its showing one record as a result.

Is your issue is resolved? Please let us know if you need further assistance with your issue.

The topic ‘[Closed] Parametric Search – By year range (2 numeric fields)’ is closed to new replies.