• Resolved carlsky

    (@carlsky)


    Hello,
    what formula can i use to calculate end time – start time ?
    And to prevent negative number after calculation?

    Thank you.

Viewing 1 replies (of 1 total)
  • Plugin Author codepeople

    (@codepeople)

    Hello @carlsky,

    Depends of the version of the plugin you are using. Assuming you have installed the Developer or Platinum version of the plugin (both include the Date/Time operations module), and that the date/time fields are the fieldname1 and fieldname2 where only the time section is enabled, the equation would be as simple as:

    
    (function(){
    var d = DATEDIFF(fieldname1, fieldname2, 'h');
    return d['hours']+':'+d['minutes'];
    })()
    

    However, if you are using any other version of the plugin, the process would be more complex, you should convert first the values into Date objects, and then apply the difference between them, and convert the result into HH:mm, similar to:

    
    (function(){
    var date1 = new Date(fieldname1*86400000),
    date2 = new Date(fieldname2*86400000),
    s = ABS(date1-date2)/1000,
    h = FLOOR(s/3600);
    m = FLOOR((s%3600)/60);
    return h+':'+m;
    })()
    

    I’m sorry, but the support service does not cover the implementation of users projects (forms or formulas), so, if you need additional help implementing your project, I can offer you a custom coding service from my private website:

    https://cff.dwbooster.com/customization

    Best regards.

Viewing 1 replies (of 1 total)
  • The topic ‘How to calculate time difference HH:MM?’ is closed to new replies.