Convert timestamp to date - painless scripting


(Bob) #1

Hi,
How to convert timestamp to date in painless script ?


(Court Ewing) #2

I moved this post from the Kibana forum because painless is an Elasticsearch driven feature.


(Bob) #3

Plop


(Ryan Ernst) #4

What type of painless script? Can you give an example request with a script, showing the field or value you want to convert?


(Bob) #5

Hi,
I have a timestamp like : 1488350778.
I want to get the month, year, semester, trimester from this timestamp.
How to do that in painless script ? For the type, I don't know, what do you recommend ?


(Ryan Ernst) #6

By "type" of painless script, I meant what part of the system are you trying to use a script in? An example request with a script, even if you just have "PUT SCRIPT HERE" for the actual script.

I have a timestamp like : 1488350778.

Do you have a field with this value, or you are passing it into the script?

I want to get the month, year, semester, trimester from this timestamp.

Month and year are doable, but semester and trimester and completely subjective (not part of any calendar system). You can certainly have fixed dates for the beginning/end of semester/trimester and detect if your given date falls within the range.


(Bob) #7

I basically want to create new fields : month and year from the timestamp.
Yes, I have a field containing the timestamp.
The goal is to create selection fields in my kibana dashboard to filter by month and year.
I also want to use month and year as dimension in my kibana visualisation.


(system) #8

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