Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

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

New Here ,
Mar 07, 2018 Mar 07, 2018

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

TOPICS
Acrobat SDK and JavaScript
807
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 07, 2018 Mar 07, 2018
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 07, 2018 Mar 07, 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 07, 2018 Mar 07, 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

.....

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 09, 2018 Mar 09, 2018
LATEST

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines