# Calculate age from birthday (type: date)

**URL:** https://discuss.elastic.co/t/calculate-age-from-birthday-type-date/6633
**Category:** Elasticsearch
**Created:** [February 8, 2012, 8:41am UTC](https://discuss.elastic.co/t/calculate-age-from-birthday-type-date/6633 "2012-02-08T08:41:31Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![CBR](https://avatars.discourse-cdn.com/v4/letter/c/ad7895/32.png) [@CBR](https://discuss.elastic.co/u/CBR)
#### Post date: [February 8, 2012, 8:41am UTC](https://discuss.elastic.co/t/calculate-age-from-birthday-type-date/6633/1 "2012-02-08T08:41:31Z")

</div>

Hello!  
As I think it's stupid to store the age itself, I need to know if and  
how it's possible to calculate the age from the stored birthday, to  
filter searchresults by the calculated age.  
[…]  
"dob":{  
"include\_in\_all":false,  
"format":"dateOptionalTime",  
"type":"date"  
},  
[…]

---

<div class="post-metadata">

### Author: ![avasilenko](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/avasilenko/32/2901_2.png) [@avasilenko](https://discuss.elastic.co/u/avasilenko)
#### Post date: [February 8, 2012, 8:44am UTC](https://discuss.elastic.co/t/calculate-age-from-birthday-type-date/6633/2 "2012-02-08T08:44:59Z")

</div>

Hello,

Date is stored as unix timestamp with milliseconds precision (java-style).  
Try to use it like long and calculate age accordingly.

Regards,  
Alexandr Vasilenko

2012/2/8 c.bieser [christian.bieser@gmail.com](mailto:christian.bieser@gmail.com)

> Hello!  
> As I think it's stupid to store the age itself, I need to know if and  
> how it's possible to calculate the age from the stored birthday, to  
> filter searchresults by the calculated age.  
> […]  
> "dob":{  
> "include\_in\_all":false,  
> "format":"dateOptionalTime",  
> "type":"date"  
> },  
> […]

---

<div class="post-metadata">

### Author: ![CBR](https://avatars.discourse-cdn.com/v4/letter/c/ad7895/32.png) [@CBR](https://discuss.elastic.co/u/CBR)
#### Post date: [February 8, 2012, 9:03am UTC](https://discuss.elastic.co/t/calculate-age-from-birthday-type-date/6633/3 "2012-02-08T09:03:28Z")

</div>

Hello Alexandr Vasilenko,  
could you give me an Example?  
I even don't know if I have to extend the mapping or if I have to  
calculate it while querying or filtering.  
Kind regards,  
Christian Bieser

On 8 Feb., 09:44, Alex Vasilenko [aa.vasile...@gmail.com](mailto:aa.vasile...@gmail.com) wrote:

> Hello,
> 
> Date is stored as unix timestamp with milliseconds precision (java-style).  
> Try to use it like long and calculate age accordingly.
> 
> Regards,  
> Alexandr Vasilenko

---

<div class="post-metadata">

### Author: ![CBR](https://avatars.discourse-cdn.com/v4/letter/c/ad7895/32.png) [@CBR](https://discuss.elastic.co/u/CBR)
#### Post date: [February 8, 2012, 11:56am UTC](https://discuss.elastic.co/t/calculate-age-from-birthday-type-date/6633/4 "2012-02-08T11:56:43Z")

</div>

Okay, I found out that it's not necessary to calculate the age to use  
it with the range-filter as it's possible to use the date-values with  
this filter.

---

<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: [July 6, 2017, 3:40am UTC](https://discuss.elastic.co/t/calculate-age-from-birthday-type-date/6633/5 "2017-07-06T03:40:08Z")

</div>


