Transform Hour and date

Hello, I am new to Kibana, I have a Table with 2 columns (dateini and date end) with format "dd / mm / yyyy hh: mm: ss". I need to change this format to "hh: mm: ss" and then do a subtraction of these 2 fields and display them in a metric.

For example: 19:01:00 - 19:00:00 = 1 minute difference

I would appreciate if you can help me.

You can create a scripted field.

int start = doc['date_filed1'].value.getHour()*3600 + doc['date_filed1'].value.getMinute()*60 + doc['date_filed1'].value.getSecond();
int end = doc['date_filed2'].value.getHour()*3600 + doc['date_filed2'].value.getMinute()*60 + doc['date_filed2'].value.getSecond();
int diff = end-start;
return diff;

This will give you the differences in seconds.

Thanks!

1 Like

Thanks, but my initial field is a string, how to convert my initial field to a date?

There are examples in the documentation.
Please read it.