Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

177
Vistas
Painless Script to get Time difference

Hi I have 2 columns as date datatype in my Kibana Index Pattern and I want to add a third column as the difference between the 2 columns: Here is sample and format of the columns:

Col1: Jun 16, 2022 , 09:00:00.000
Col2: Jun 16, 2022 , 09:10:07.999

Now I want to have a third column as TimeDifference in the following format:

TimeDiff: 00:10:07.999

Can anyone help me with the script please I tried a few but everytime it complains about invalid script, here is the script that I tried and it failed:

def diffInMs = doc['col2'].value.getMillis() - doc['col1'].value.getMillis();
def duration = Duration.ofMillis(diffInMs);
def hours = duration.toHours();
def minutes = duration.minusHours(hours).toMinutes();
def seconds = duration.minusHours(hours).minusMinutes(minutes).getSeconds();
def str = hours + ':' + minutes + ':' + seconds;
return str;

It would be really helpful if anyone could point out what did I miss out in this script. Thanks

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda