Skip to main content
Participating Frequently
March 7, 2018
Question

how to calculate time difference between two field and give the answer in a third one using decimal hours

  • March 7, 2018
  • 2 replies
  • 878 views

i need this to happen automatically

        

startshutdowndifference (decimal hours)
12:3412:440.2 hours
13:0013:210.4 hours
13:4015:01

1.4 hours

This topic has been closed for replies.

2 replies

Inspiring
March 7, 2018

There are some additional issues you need to provide information about.

1. Will the time interval ever span more than 1 date?

     If so, you will need to include the dates for the start and end.

2. You are rounding to the nearest 1/10th of an hour, since JavaScript uses IEEE floating point to store numbers, you will need to provide a rounding routine for the floating point number unless you can live with the fractional values in the result beyond 1/10th of an hour.

Participating Frequently
March 7, 2018

time will always span on the same day/date

and

we have predetermined time decimals ex:

from 1 to 6 = 0.1

from 6 to 14= 0.2

from 15 to 20=0.3

.....

Inspiring
March 9, 2018

With only hours an minutes, this calculation will not work when the interval includes the time changes due to Day Light Saving Time, British Summer Time, or other adjustment to local time to adjust for the hours of daylight. If the date is included JavaScript will automatically adjust for the 1 hour change in the local time.

try67
Community Expert
Community Expert
March 7, 2018