Get the date right now

(radi) #1

i have filed lastDate i whant to make script filed to calcul the diffrence of the value of lasteDate and the actual date
there is way to get actual date in kibana ?


Return value of null
(Joe Fleming) #2

By "actual date" I think you're talking about the date right now.

Scripted fields in Kibana simply use Elasticsearch's Painless scripting language. Unfortunately, that language can only be used to work with numbers, booleans, voids, and arrays. Since there is no way to operate on dates in the language, there is no way to calculate the difference between dates in scripted fields.

(Joe Fleming) #3

Ah, Painless doesn't support dates, but the expression syntax does. It's not clear to me how you'd get the current date to do the calculation with though.

(radi) #4

Thank you for your return. I used groovy to calculate the current date. and it's working good

(Joe Fleming) #5

Mind sharing how you got the current date in the Groovy script? I couldn't find an example that did that, and it would be useful to know what that looks like.

(radi) #6
this is my script_fields i called current data with ""

and i used it to compare with my session date

"script_fields" : {
      "Checks" : {
          "script" : {
         "lang": "groovy",
         "doc['sessionDate'].collect{ if (it!=0){ 
         if (((*60*60*24))<60) 
         'check ok';else  'check no';   }else 'Never check'; }"

(system) #7

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