Support Forums

The forums are closed and will be removed when we launch our new site.

Looking for support? You can access the support system via your account.

Forums Forums Search & Filter Pro No Results – DateTime Range

Tagged: 

Viewing 8 posts - 1 through 8 (of 8 total)
  • Matt
    #206984

    I’ve setup a search form that should filter out post by a Date Range. The field has a datetime value. It works for a simple date dropdown of values found in the DB, but it doesn’t return any results when I use the same field for a Range filter.

    Trevor Moderator
    #206989

    At the moment, in the current version of our plugin, (other than the Post date field) we only support fields with ordinary numbers, or dates stored in the format YYYYMMDD. We do not support date/time or time fields, I am sorry.

    Matt
    #206995

    Would it be possible to intercept the query and alter the query using sf_edit_query_args.

    I would do something like this in that filter

                $start = '2016-01-01 00:00:00';
                $end = '2016-12-31 23:59:59';
    
                $query_args['meta_key'] = '_audiotheme_gig_datetime';
                $query_args['meta_query'] = array(
                        'key'     => '_audiotheme_gig_datetime',
                        'value'   => array( $start, $end ),
                        'compare' => 'BETWEEN',
                );

    Ideally I just need to alter the query prior with my own arguments around a specific meta field.

    Matt
    #207000

    I’ve made some progress with this.
    I can alter the query by adjusting the meta_query as above but I need to remove a fields value from $sf_current_query. When I unset it the query is still run like it’s there.
    I removed it like this
    unset($sf_current_query['_sfm__audiotheme_gig_datetime']);

    Trevor Moderator
    #207067

    Did you print out the query array to make sure that was the element you needed to remove?

    Matt
    #207161

    Yes, and the element was removed, but it had no effect on the query. It still processed it as if the element was in the query.

    So I had to work around it by unsetting the element that was set in the $_GET variable. It works for now, but I was sure it would have been straight forward using the sf_edit_query_args function.

    Trevor Moderator
    #207163

    This is now resolved?

    Matt
    #207304

    Yes. Thank you

Viewing 8 posts - 1 through 8 (of 8 total)

The topic ‘No Results – DateTime Range’ is closed to new replies.