# Current date on Script Field

**URL:** https://discuss.elastic.co/t/current-date-on-script-field/31510
**Category:** Kibana
**Created:** [October 1, 2015, 9:34pm UTC](https://discuss.elastic.co/t/current-date-on-script-field/31510 "2015-10-01T21:34:22Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![nmgnr](https://avatars.discourse-cdn.com/v4/letter/n/e480ec/32.png) [@nmgnr](https://discuss.elastic.co/u/nmgnr)
#### Post date: [October 1, 2015, 9:34pm UTC](https://discuss.elastic.co/t/current-date-on-script-field/31510/1 "2015-10-01T21:34:22Z")

</div>

I'm trying to generate a script field in Kibana 4 and I need to compute the difference between a date field and the current date:

(current\_date - doc['startDate'].value)

I would also like to know if there is a way I could use the date range (from-to) of every kibana query in the script field. ex:

(to\_date - doc['startDate'].value)

Any help?

Thanks!

---

<div class="post-metadata">

### Author: ![tbragin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tbragin/32/45166_2.png) [@tbragin](https://discuss.elastic.co/u/tbragin)
#### Post date: [October 6, 2015, 5:04am UTC](https://discuss.elastic.co/t/current-date-on-script-field/31510/2 "2015-10-06T05:04:56Z")

</div>

[Lucene expressions](https://lucene.apache.org/core/5_2_0/expressions/index.html?org/apache/lucene/expressions/js/package-summary.html), which is the default scripting language, does not support date math. For date support, you can switch to Groovy, using dynamic (insecure!) or [static](https://discuss.elastic.co/t/calling-groovy-script-from-kibana/2542/3?u=tbragin) scripts.

---

<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, 2:11pm UTC](https://discuss.elastic.co/t/current-date-on-script-field/31510/3 "2017-07-06T14:11:53Z")

</div>


