How to calculate date and time difference?

  • evensbelizaire
    Demandé le 28 juin 2023 à 02:34
    Is it possible to have the duration between the dateIn field and the dateOut field?
  • Angeli Jotform Support
    Répondu le 28 juin 2023 à 03:04

    Hi evensbelizaire,

    Thanks for patiently waiting. Yes, this is possible. You can subtract one Date Picker field from another to get the difference. I'll walk you through setting that up:

    • Add a Form Calculation widget and Subtract the DateOut to DateIn.

    How to calculate date and time difference? Image 1 Screenshot 60

    • The results will be in decimal so you'd need to add another Form Calculation widget to get the absolute result. 
    • Add the Floor formula by clicking the 3 dots icon and put the Raw Date difference between the open and close parenthesis.

    How to calculate date and time difference? Image 2 Screenshot 71

    Now, to get the time, we'll add 3 Form Calculation widgets. Here's the formula:

    • Subtract the Raw Date difference to its rounded result then multiply it by 24.

    How to calculate date and time difference? Image 3 Screenshot 82

    • Add the Floor formula and the result in the Raw Hours and Minutes to get the Hours.

    How to calculate date and time difference? Image 4 Screenshot 93

    • And copy the formula below to get the Minutes.

    How to calculate date and time difference? Image 5 Screenshot 104

    You can clone this demo form to inspect or test. We also have a guide about Performing Date and Time Calculations that you can check out.

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

  • evensbelizaire
    Répondu le 28 juin 2023 à 20:50

    Bonjour Angeli

    Merci pour les formules, elles fonctionnent très bien!.

    Mais j'aimerais avoir le résultat en heure et en minutes seulement (pas de jour),

    J'ai utilisé cette formule 

    How to calculate date and time difference? Image 1 Screenshot 20


    Mai on dirait qu'il manque quelque chose. Peux-tu vérifier svp



    Hello Angeli

    Thanks for the formulas, they work very well.

    But I would like to have the result in hours and minutes only (not days),

    I used this formula 

    (capture)


    But it looks like something is missing. Can you please check please



  • Ravi Jotform Support
    Répondu le 29 juin 2023 à 03:22

    Hi evensbelizaire,

    Thanks for getting back to us. In that case you need to update the calculation for Hours Field. Your updated calculation for Hour Field will look like the below screenshot :

    How to calculate date and time difference? Image 1 Screenshot 20

    I have made changes in the cloned form. Here is the link to the clone form. If needed you can clone my form to check the calculation in widgets. We also have a guide on How to Clone an Existing Form From a URL that you can check out.

    Reach out again if you need any other help.