# Partial date search on Date Of Birth Fields

**URL:** <https://discuss.elastic.co/t/partial-date-search-on-date-of-birth-fields/206023>\
**Category:** Elasticsearch\
**Created:** [October 31, 2019, 10:34am UTC](https://discuss.elastic.co/t/partial-date-search-on-date-of-birth-fields/206023 "2019-10-31T10:34:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pushpak\_Chavan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pushpak_chavan/32/56926_2.png) [@Pushpak\_Chavan](https://discuss.elastic.co/u/Pushpak_Chavan)\
**Post date:** [October 31, 2019, 10:34am UTC](https://discuss.elastic.co/t/partial-date-search-on-date-of-birth-fields/206023/1 "2019-10-31T10:34:10Z")

</div>

Hi,  
I have one field which is dateofbirth whose mapping is something like below  
"dateofbirth" : {  
"type" : "date",  
"fields" : {  
"tokens" : {  
"type" : "text"  
}  
},  
"ignore\_malformed" : true,  
"format" : "yyyy-MM-dd"  
},  
I have a use case where i need to search on the basis of yyyydd & yyyy & yyyyMM, Does any one know how to apply analyzer in such case, so that tokens can be created for searching.

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [October 31, 2019, 12:47pm UTC](https://discuss.elastic.co/t/partial-date-search-on-date-of-birth-fields/206023/2 "2019-10-31T12:47:25Z")

</div>

A date gets converted to the milliseconds since the epoch (midnight in 1970) and a query will be a range query. You can specify the format when querying, that should just include the year or month. See [https://www.elastic.co/guide/en/elasticsearch/reference/7.4/query-dsl-range-query.html#range-query-field-params](https://www.elastic.co/guide/en/elasticsearch/reference/7.4/query-dsl-range-query.html#range-query-field-params)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [November 28, 2019, 12:47pm UTC](https://discuss.elastic.co/t/partial-date-search-on-date-of-birth-fields/206023/3 "2019-11-28T12:47:35Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
