0

I used below simple expression for getting duration:

doc['endTime'].date.millisOfDay - doc['startTime'].date.millisOfDay

But the problem starts when, endTime crosses the startTime day.

Example: If startTime is 23:50 and endTime for the same is 00:12, we crossed by midnight, which changes the date as well.

In that way I am getting absolutely wrong duration, except all the scenarios when both time lies with in the same day result is as expected.

Help on how exactly i can make this.

Indrajeet Gour
  • 4,020
  • 5
  • 43
  • 70

1 Answers1

0

You should simply subtract the absolute milliseconds value since the epoch (instead of milliseconds since the start of the day):

doc['endTime'].date.millis - doc['startTime'].date.millis
Val
  • 207,596
  • 13
  • 358
  • 360