# How to pass in \`current\_unix\_time\` as a value for elasticsearch query?

**URL:** <https://discuss.elastic.co/t/how-to-pass-in-current-unix-time-as-a-value-for-elasticsearch-query/331385>\
**Category:** Elasticsearch\
**Tags:** painless, runtime-fields\
**Created:** [April 30, 2023, 10:44pm UTC](https://discuss.elastic.co/t/how-to-pass-in-current-unix-time-as-a-value-for-elasticsearch-query/331385 "2023-04-30T22:44:27Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)\
**Post date:** [April 30, 2023, 11:17pm UTC](https://discuss.elastic.co/t/how-to-pass-in-current-unix-time-as-a-value-for-elasticsearch-query/331385/2 "2023-04-30T23:17:31Z")

</div>

Hi @learningelastic

Let's back up a bit

> [@learningelastic](#):
>
> "How many days have passed since [today]"

I am confused what you are actually trying to accomplish....

Are you trying to calculate the number of days from Today / Now with respect to a date field in the document?

> [@learningelastic](#):
>
> I understand that I can NOT put in a unix time as part of my painless

I am not sure where that understanding comes from...

Perhaps you are looking to do something like this

> [@Calculate elapsed time in Kibana?](https://discuss.elastic.co/t/calculate-elapsed-time-in-kibana/316575/2):
>
> Hi @TXBigDawg1836 Welcome to the community Yup add a runtime field to the Data View here is the code long datenow = new Date().getTime(); long datewas = doc['@timestamp'].value.getMillis(); emit (datenow - datewas); Create / Set the Field Chose your format.... In Discover Now Table...

---

_[View the full topic](https://discuss.elastic.co/t/how-to-pass-in-current-unix-time-as-a-value-for-elasticsearch-query/331385)._
