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.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.