# Age from year of birth

**URL:** https://discuss.elastic.co/t/age-from-year-of-birth/298280
**Category:** Elasticsearch
**Created:** [February 25, 2022, 1:03pm UTC](https://discuss.elastic.co/t/age-from-year-of-birth/298280 "2022-02-25T13:03:06Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Anand\_p\_s](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/anand_p_s/32/102340_2.png) [@Anand\_p\_s](https://discuss.elastic.co/u/Anand_p_s)
#### Post date: [February 25, 2022, 1:03pm UTC](https://discuss.elastic.co/t/age-from-year-of-birth/298280/1 "2022-02-25T13:03:06Z")

</div>

Sir,  
I need to do a range aggeration for age ,from year of birth field.  
How it possible .  
Pls help

---

<div class="post-metadata">

### Author: ![DineshNaik](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dineshnaik/32/89308_2.png) [@DineshNaik](https://discuss.elastic.co/u/DineshNaik)
#### Post date: [February 25, 2022, 1:32pm UTC](https://discuss.elastic.co/t/age-from-year-of-birth/298280/2 "2022-02-25T13:32:42Z")

</div>

Hi Anand,  
Welcome to the community.  
you can try something like this

```auto
POST /your_index/_search?size=0
{
  "aggs": {
    "range": {
      "date_range": {
        "field": "date",
        "format": "MM-yyyy",
        "ranges": [
          { "to": "now/d" },  
          { "from": "date-of-birth" } 
        ]
      }
    }
  }
}

```

you need to change date-of-birth and provide your\_index name . Also refer [Date range aggregation | Elasticsearch Guide [8.0] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-daterange-aggregation.html) for more details

---

<div class="post-metadata">

### Author: ![Anand\_p\_s](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/anand_p_s/32/102340_2.png) [@Anand\_p\_s](https://discuss.elastic.co/u/Anand_p_s)
#### Post date: [February 26, 2022, 7:16am UTC](https://discuss.elastic.co/t/age-from-year-of-birth/298280/3 "2022-02-26T07:16:24Z")

</div>

Thanks for your answer @DineshNaik . It help me a lot 👏 👏 👏 🤲 .

---

<div class="post-metadata">

### Author: ![DineshNaik](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dineshnaik/32/89308_2.png) [@DineshNaik](https://discuss.elastic.co/u/DineshNaik)
#### Post date: [February 26, 2022, 7:05pm UTC](https://discuss.elastic.co/t/age-from-year-of-birth/298280/4 "2022-02-26T19:05:29Z")

</div>

You are welcome!

---

<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: [March 26, 2022, 7:05pm UTC](https://discuss.elastic.co/t/age-from-year-of-birth/298280/5 "2022-03-26T19:05:54Z")

</div>

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