After some research on wp codex I found my solution. Here I have to change birth_date format during save.
I saved value like yy-mm-dd
this format and changed my meta_query
Here is the code
$studentdata = get_users(
array(
'meta_query'=> array(
array(
'key' => 'birth_date',
'value' => array(
$startyear.'-01-01',$endyear.'-12-31'),
'compare' => 'BETWEEN',
)
),
'role'=>'student'
)
);
print_r($studentdata);
Related Posts:
- How to handle optional end date in compare clause in meta_query
- Arrange Posts By Date In Order Of Closest To The Current Date
- User Relationship
- How to pass user meta_key and meta_value (values as array)
- Query posts with numeric meta values within a given range
- last_name + first_name orderby with meta_query [solved]
- Meta Query Based on Month Range
- how to search all user meta data that have value like “vivek”
- get_users with Serialized Custom Meta Value
- Ordering custom posts by meta field date
- get_user can’t read variable
- Query for user roles and their skills
- How to compare date in post meta value
- wp_user_query with meta_value_num for leaderboard
- Meta query terribly slow
- Query between two meta keys
- How to check a single number value against an array of meta_key values?
- WP_User_Query with combined meta query – not working?
- Meta query with multiple logic (AND / OR)
- Best practice – Meta Query vs. post_clauses for “left join” ordering
- How to add follow functionality to multi-author wordpress site?
- Search multiple meta keys at once
- LIKE %…% Meta Query
- Multiple Values stored as array in Meta Query
- Documentation for post meta
- Advanced orderby with multiple meta_query
- delete_user_meta Delete one value out of array
- Very slow query with meta_query on large database
- How to use meta_query to check if a meta field has something set?
- Displaying posts with only upcoming dates according their custom field date value
- Use meta_query to display events by date in custom field
- meta_query results not the same with and without spaces
- How to show recent and upcoming birthdays using meta_query
- meta_query all posts between to ages
- How to make a WP REST API query with meta_query in WP4.7?
- Nested Queries using meta_query
- WP User Query fails when searching meta queries and search columns
- Wildcard with LIKE operator in Meta query
- WP_Query meta_query >= date
- Filter WooCommerce Orders query with user meta data
- WP_Query ordered by meta_value_num doesn’t fetch posts without this meta field
- Query Multiple values for same key
- Custom post type archive with rand and meta_value
- Comparing a field with several values at once with meta_query
- Meta query with a sub query group possible?
- WP_user_query throws a 404 error
- meta_query compare=’!=’ with multiple custom fields
- How do you get Posts by multiple meta_keys and meta_values with the Rest API V2?
- Query custom field with date
- Searching in title or meta, with a tax query too!
- Meta query: How do I return posts within a date period from a given month?
- WP_Query with meta_query no results
- Documentation for post meta
- Meta Query posts not showing on ending date of custom field
- Pre Get Posts / Multiple Meta Keys / Orderby Single Key
- WordPress Screwing Up ‘orderby’ => ‘meta_value_num’ in ‘pre_get_posts’
- How to query wp_postmeta table for any specific meta_value?
- User meta query results in PHP notice: only variables should be passed by reference
- meta_query with multiple values optimization
- Get a single post ID based on an exact match of 1 or more meta values
- wordpress Meta_query between numbers range (not working)
- meta_query with multiple key
- Order by meta value
- Query post by date (stored custom field meta as yyyymmdd) and differentiate across 12 months
- ACF: How to get users with a ACF flexible content subfield with a specific value AND layout?
- meta query based on month regardless of year
- meta_query in WP_User_Query not working – returns every user, not just users where key & value matches
- User Meta Value not echoing despite Var_Dump Showing correct string
- meta query or with meta value
- meta_query array in ‘values’ returns an error
- WP JSON API meta_query not working
- Show single posts date, in a page of posts
- Using WP meta query to show custom post types by a start and finish date
- How to properly escape values in meta query
- How to Ordering by user meta
- How do I echo all users’ display_name and their meta_value who have a certain meta_key?
- How to send variable to wp meta_query value?
- How to do WP_User_Query for Nested Array value Inside Nested Array field
- meta_query check multiple date formats
- Unusual high query of user meta data
- Why does this incorrect pre_get_posts meta_query work for sort order?
- Meta_Query with multi select values
- How to sort custom posts including null meta-values in admin columns with meta_query?
- Get Posts from Custom Meta Query
- Get meta_query value by user meta array
- How to fetch WP_User_Query with multiple role arguments [duplicate]
- How to get meta value based on latest post id with group by term name
- Multiple Queries with meta_query
- Get foreach for meta_query value
- list or get meta_key where meta_value is ‘something’
- meta_query and strange orderby behaviour
- Sorting not working with get_posts
- order by meta_key [duplicate]
- Get all user with both meta_value
- WordPress Meta Query very slow with NOT EXISTS comparison
- ACF meta_query field treated as “0” resulting in false negative search when testing ranges
- WP_Query() displaying past post / event
- Is it possible to customize meta query in this way?
- Ordering WP_Query results by second meta_key
- How making a new search box in admin post table working on a specific column