# Groovy to Painless; get current date time

**URL:** <https://discuss.elastic.co/t/groovy-to-painless-get-current-date-time/95471>\
**Category:** Elasticsearch\
**Created:** [August 2, 2017, 7:34am UTC](https://discuss.elastic.co/t/groovy-to-painless-get-current-date-time/95471 "2017-08-02T07:34:34Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![rjernst](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rjernst/32/6363_2.png) [@rjernst](https://discuss.elastic.co/u/rjernst)\
**Post date:** [August 2, 2017, 4:15pm UTC](https://discuss.elastic.co/t/groovy-to-painless-get-current-date-time/95471/2 "2017-08-02T16:15:24Z")

</div>

See this previous thread which explains what to do (passing in `now` through a param):

> [@Painless get date today](https://discuss.elastic.co/t/painless-get-date-today/81264/2):
>
> Painless intentionally doesn't have any access to now style variables so they can be better cached. The current recommendation is for you to send now style variables in over scripts params. BTW, you should know that this query isn't able to take advantage of the index at all. It'll have to load the @timestamp field for every document and compare it. This much much slower than extracting the day of the week on ingest and adding it to the document.

---

_[View the full topic](https://discuss.elastic.co/t/groovy-to-painless-get-current-date-time/95471)._
