Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

192
Views
Time calculations using HH:MM and over 24 hours

I am using below but I need the output to be in decimal time. This is for travel computations and our travel will often travel over the 24:00 time mark.

// Time Values
   var cStartTime = this.getField("DT OT L1").value;
   var cEndTime = this.getField("AT OT L1").value;

   // Only process if field contains a value
    if ((cStartTime != "") && (cEndTime != "")) {
    // Convert to Hours Decimal value
    var nStartTime = 0,
        nEndTime = 0;


    var aStartTime = cStartTime.split(":");
    nStartTime = Number(aStartTime[0]) + Number(aStartTime[1]) / 60;
    var aEndTime = cEndTime.split(":");
    nEndTime = Number(aEndTime[0]) + Number(aEndTime[1]) / 60;



   // Find Difference
    var nTimeDiff = nEndTime - nStartTime;

   // Test for Midnight Crossover
    if (nTimeDiff < 0) { // Shift 24 hours
        nTimeDiff += 24;
    }


   // If used in a calculation, may need to be changed to "event.value ="
    var nHours = Math.floor(nTimeDiff);
    var nMinutes = Math.floor((nTimeDiff - nHours) * 60 + 0.5);
    event.value = util.printf("%02d:%02d", nHours, nMinutes);
    } else
    event.value = "";
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!