Calculate the number of days

  • Profile Image
    Cristallina83
    Asked on February 23, 2018 at 05: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.

  • Profile Image
    EltonCris
    Answered on February 23, 2018 at 05: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:

    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.

  • Profile Image
    Cristallina83
    Answered on February 23, 2018 at 05: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.4

    It says: difference: 2 days.

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

    Thanks for your support!

  • Profile Image
    Kevin_G
    Answered on February 23, 2018 at 08:52 PM

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

    15194370611.png

    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: 

    15194371122.png

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

    I hope this helps. 

  • Profile Image
    Cristallina83
    Answered on February 24, 2018 at 07:35 AM

    Thank you Kevin!

    I did it and it works perfectly!