Support

Account

Home Forums General Issues acf query date Reply To: acf query date

  • You can’t do the query like that. The date picker stores the date in a single field in the format YYYYMMDD. You would need to do something like this

    
    meta_query => array(
      'relation' => 'AND',
      array(
        'key' => 'date_picker_field_name',
        'value' => $first_day_of_month,
        'compare' => '>='
      ),
      array(
        'key' => 'date_picker_field_name',
        'value' => $last_day_of_month,
        'compare' => '<='
      )
    )
    

    where $first_day_of_month and $last_day_of_month are dates in the proper format.

    Alternately you could create an acf/save_post filter that takes the value stored by ACF and creates values in two additional fields, one for year and another form month and then you those additional fields when performing the query.