How to calculate the duration of two date and time fields

  • Profile Image
    caseySOFU
    Asked on May 17, 2022 at 02:17 PM

    Hi! If we capture a start date and time and an end date and time, is there a way for the system to calculate the duration?


    Thank you


    Casey

  • Profile Image
    Rose
    Answered on May 17, 2022 at 04:34 PM

    Hi Casey,

    I am currently working on your concern and need more time. I will get back to you shortly. Thank you.


  • Profile Image
    Rose
    Answered on May 17, 2022 at 05:41 PM

    Hi Casey,

    To calculate the Date and Time duration, you need to add multiple Form Calculation widgets to your form. Then, add the following formula in each corresponding widget:

    1652823225_628414b9b13d0_

    To get the raw difference between the 2 date and time fields:

    1652823124_628414540e8ad_

    To get the days difference:

    1652823171_6284148331f15_

    To get the raw hours and minutes difference:

    1652823199_6284149f6fbc2_

    To get the hours difference:

    1652823255_628414d7d7101_

    To get the minutes difference:

    1652823281_628414f160644_

    Then, to summarize the total duration difference, you can add a Pharagraph element and add the unique name of the days, hours, and minutes field.

    1652823439_6284158f4ec76_

    I also suggest that you hide the calculation widgets from the form view:

    1652823511_628415d771567_

    Here's the output:

    1652823654_628416661dd0c_

    Here's the clone form https://form.jotform.com/221366853182963, you may view it for demo purposes or you can also clone it.

    Please give it a try and let us know if you need any help.