# How to get current date using painless langage

**URL:** <https://discuss.elastic.co/t/how-to-get-current-date-using-painless-langage/137820>\
**Category:** Elasticsearch\
**Created:** [June 28, 2018, 3:46pm UTC](https://discuss.elastic.co/t/how-to-get-current-date-using-painless-langage/137820 "2018-06-28T15:46:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![lutundula\_jeanchris](https://avatars.discourse-cdn.com/v4/letter/l/919ad9/32.png) [@lutundula\_jeanchris](https://discuss.elastic.co/u/lutundula_jeanchris)\
**Post date:** [June 28, 2018, 3:46pm UTC](https://discuss.elastic.co/t/how-to-get-current-date-using-painless-langage/137820/1 "2018-06-28T15:46:14Z")

</div>

I just started coding in painless and i am looking for a way to get the current date , the current date - 1 day . i see so many functions and iam a bit lost , can someone help me .

Thanks

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [June 29, 2018, 2:21pm UTC](https://discuss.elastic.co/t/how-to-get-current-date-using-painless-langage/137820/2 "2018-06-29T14:21:05Z")

</div>

can you explain a bit, what you are after and where you need this timestamp? Is there a chance you can inject it externally from your application via script parameters?

---

<div class="post-metadata">

**Author:** ![lutundula\_jeanchris](https://avatars.discourse-cdn.com/v4/letter/l/919ad9/32.png) [@lutundula\_jeanchris](https://discuss.elastic.co/u/lutundula_jeanchris)\
**Post date:** [June 29, 2018, 2:37pm UTC](https://discuss.elastic.co/t/how-to-get-current-date-using-painless-langage/137820/3 "2018-06-29T14:37:21Z")

</div>

Hey , thanks for helping here's what i want to do in painless on my ELK

long datenow = new Date().getTime();  
String domain ;  
long previousdate = datenow - 860000 ;  
for (from date now to previousdate) #thats the idea  
{  
domain += doc['usrName.keyword'];  
}  
return domain; #return all the domains

the goal its to inject it via script parameter (on a vizualise)

---

<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 27, 2018, 2:37pm UTC](https://discuss.elastic.co/t/how-to-get-current-date-using-painless-langage/137820/4 "2018-07-27T14:37:30Z")

</div>

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