Calculate the number of days

  • Cristallina83
    Asked on February 23, 2018 at 5:01 PM

    Hi again Richie,

    is there a way I can have a sort of add-on to help me calculating how many nights are selected?

    Example:

    I have check-in date: 04.06.2018 and check-out date at 08.06.2018. It is 4 nights stay.

    Is there a widget that inserting a date for check-in and check-out automatically calculates me the nights?

    Thanks in advance.

  • Elton Support Team Lead
    Replied on February 23, 2018 at 5:21 PM

    If you are using the date picker fields, that is possible using the update/calculation condition. Guide: https://www.jotform.com/help/268-How-to-Insert-Text-or-Calculation-into-a-Field-Using-Conditional-Logic

    Example:

    Calculate the number of days Image 1 Screenshot 30

    There's also a widget that is designed for this purpose https://widgets.jotform.com/widget/dates_difference

    To get the date difference value, just use form calculation widget and add the date difference widget in the calculation wizard.

    Calculate the number of days Image 2 Screenshot 41

  • Cristallina83
    Replied on February 23, 2018 at 5:49 PM

    Thank you so much Elton.

    Is it possible to see just the number without any other character?

    I show you how it shows.

    1519426090Schermata 2018 02 23 alle 23 Screenshot 10

    It says: difference: 2 days.

    I would like to see only the number 2 if possible.

    Thanks for your support!

  • Kevin Support Team Lead
    Replied on February 23, 2018 at 8:52 PM

    You should make sure that the date differences widget returns the difference only: 

    Calculate the number of days Image 10

    Once you have done this, you need to change the field included on the form calculation widget, click on it to include it as numeric value instead of text: 

    Calculate the number of days Image 21

    Result: https://form.jotform.com/80537507230956 

    I hope this helps. 

  • Cristallina83
    Replied on February 24, 2018 at 7:35 AM

    Thank you Kevin!

    I did it and it works perfectly!