# Calculate "age" as scripted field

**URL:** https://discuss.elastic.co/t/calculate-age-as-scripted-field/115274
**Category:** Elasticsearch
**Created:** [January 12, 2018, 10:41am UTC](https://discuss.elastic.co/t/calculate-age-as-scripted-field/115274 "2018-01-12T10:41:31Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![emil.mirzayev](https://avatars.discourse-cdn.com/v4/letter/e/ba9def/32.png) [@emil.mirzayev](https://discuss.elastic.co/u/emil.mirzayev)
#### Post date: [January 12, 2018, 10:41am UTC](https://discuss.elastic.co/t/calculate-age-as-scripted-field/115274/1 "2018-01-12T10:41:31Z")

</div>

Hi. I have an Event table where for every document I have a timestamp. I want to have a scripted field Lifetime which is today - timestamp of an event converted do days(weeks). How I do it with painless? I am not very good for programming.  
Is it also possible to have this field a dynamically changing?

---

<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: [February 9, 2018, 10:41am UTC](https://discuss.elastic.co/t/calculate-age-as-scripted-field/115274/2 "2018-02-09T10:41:37Z")

</div>

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