How to get the date difference in hours and minutes?

  • Profile Image
    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,

    1608048495_5fd8df6f01754_Deadline Planne

    Screenshot
  • Profile Image
    Gustavo_H
    Answered on December 15, 2020 at 01: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 😀✨

  • Profile Image
    WestAtlantic
    Answered on December 15, 2020 at 03: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.

  • Profile Image
    KrisLei
    Answered on December 15, 2020 at 08: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.

  • Profile Image
    KrisLei
    Answered on December 16, 2020 at 04: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_

    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