Extract the year from a date

Hello,
i have data stored in elasticsearch with a field called transaction_date mapped as a date ,this is its structure in the csv file 2/24/2017;14:15:43 and this how it is viewed in kibana April 18th 2016, 15:15:44.000 .In fact , i want to perform calculations using aggregatiuons with scripted field but i want to extract only data of the year 2016 .how can i extract only the year from the date field ???? any help

It's better to solve this problem at index time.

If your field is a date field, you can just generate a date histogram with a year size bucket and that will do what you expect.

Hi , thank you for your reply but i didn't get it are you talking about a bucket using kibana ???
in fact i need to divide my data into two bucket one for the year 2016 and one for the year 2017 , i know i can make it with aggregations using kibana visualization but i need to extract a metric from the buckets i mentionned then perform an other calculation with both results obtained .

I am trying to use scripted metrics with elasticsearch ? i don't know even if this can lead me to my goal ?? i need your consult !!! even more i am confused between aggregations and using painless to perform this calculation !! any help

Any suggestions please ???

Please read be patient section at

May be your question is more for Kibana? So may be move it to kibana instead?
I believe you can do something similar with time series visual builder.

sorry if i hadn't been patient :wink:

Its better to show some sample data along with the output format you need. No one can help with these type of inputs. Be more specific.

hi ,
thankyou for you reply, maybe i get into details in my question but my main purpose is to perform calculations with elasticsearch then store the results . is there any API that allow me to do this ?

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