How to get the date difference in hours and minutes?

  • WestAtlantic
    Asked on December 15, 2020 at 11:05 AM

    Hello,

    I've read the guide on 'Mastering Date & Time' but my project falls a little out of the scope and I can't get it to work fully.

    In essence, the form will be used to track the tasks which are due to be completed before a deadline. I am talking hours and minutes here, not days.

    See screenshot attached for more info and where it's going wrong (getting the calculated deadline back into HH:mm format).

    Thanks for any feedback,

    answers Screenshot 10

    Jotform Thread 2767832 Screenshot
  • Gustavo_H
    Replied on December 15, 2020 at 1:23 PM

    Hi, WestAtlantic.


    I have cloned your form also followed the guide below, but I could get the difference between Deadline and Actual in hours and minutes. 

    Complete guide 👉 mastering-date-and-time-calculation

    Can you please check this form example? I recommend you to clone it using the guide below to take a look at the formulas if this is what you need.

    Complete guide 👉 how-to-clone-an-existing-form-from-a-url

    If you just need to get the time difference, maybe you can do that more straightforward by using Time elements. You may want to check this similar ticket regarding this.


    Please, let us know if you need any further assistance 😀✨

  • WestAtlantic
    Replied on December 15, 2020 at 3:43 PM

    Hi Gustavo, Thanks for the response but your missing the issue here.

    I don't want to calculate the time difference between two user input times. It is one user input time (1) and then a calculated time (2) which is (1) minus a set amount (in this case 1 hour).

    On the image I posted above, the issue is with the "Plan" field where the HH & MM are blank.

    Also, it appears the formula on yours is incorrect, if you're 1 hour late for example, the "difference" says 23 hours.

  • KrisLei Jotform Support
    Replied on December 15, 2020 at 8:10 PM

    Hello,

    To my understanding, the result in the Equals field is not showing on the Plan field correct? It seems that you would still need to convert the values on the Equal field to pass the value on a Date Picker field.

    Please allow me some time to further check your form. I will get back to with the fix. Thank you.

  • KrisLei Jotform Support
    Replied on December 16, 2020 at 4:21 AM

    Apologies for the late response.

    I have made several test to pass the value on the time field from the Form Calculation widget through conditions and in different format. However, it seems that it is not possible to pass the values from the widget into the Date and Time field.

    1608109425 5fd9cd71de2df  Screenshot 10

    I would recommend using a separate Time field for the output.

    Your calculations for the dates are correct, but you would also need to have a separate calculations to convert the values for the time, then deduct it from the calculated number of days.

    I have a test form in progress, but I'm still trying to find a way to pass the converted time value into the stand alone Time field. You may check the calculations on my form: https://form.jotform.com/203497212111949

    You may also consider checking my colleagues method in combining the Time and Minutes in HH:MM format on this ticket: https://www.jotform.com/answers/1201940