Date and Time elements can be used in calculations for a variety of circumstances such as calculating the number of days of a reservation or calculating a user's age. Learn more about the Calculation Element.
You will need to divide by the following numbers to get the applicable length of time in your calculation. Information on how to set up these formulas can be found in the instructions below.

Hours: divide by 3600000
 Example Formula: ROUND(({ELEMENT:End_Time}  {ELEMENT:Start_Time) / 3600000, 2)

Days: divide by 86400000
 Example Formula: ({ELEMENT:Date_of_Departure}  {ELEMENT:Date_of_Arrival}) / 86400000

Years: divide by 31540000000
 Example Formula: ROUND(({ELEMENT:Current_Date}  {ELEMENT:Date_of_Birth}) / 31540000000, 1)
Article Navigation
Calculate Time
In this example, we are calculating the difference between a start time and an end time within a day. The result displays the amount of time in hours.
Instructions

Create or edit an existing form and navigate to the Builder tab
 Add your Time Elements to the form
 Add a Calculation Element
 Add a Label for the element
 Under the Calculation field, click the ROUND option
 Click inside the parentheses () and select the end time element from the Insert Element dropdown
 Add a minus sign (  ) after the element bracket
 Click Insert Element and select the start time element
 Add a divide sign ( / ) after the parentheses
 Enter the following numbers to calculate the time in hours: 3600000, 2
Note: The 2 after the comma refers to how many decimal places you would like the calculation to display. If you do not wish to show decimal places, you can add a 0, however, the calculation will then round up to the nearest whole number.  Add parentheses to the start of the formula (after the ROUND) and to the end of the formula
 In the Calculation Content field, add any additional context for end users such as the word "hours"
 Click the Save button in the top right corner
 Your form will now calculate the total number of hours entered
 If needed, you can add Conditional Logic based on how many hours a user has selected. In the example below, we set up a Calculation element that will charge users a specific rate if the reservation is 4 hours or less. We also set up a separate calculation element that will charge users a different rate if the reservation is more than 4 hours.
 The Total Reservation Cost will now reflect the user's selections
Calculate Days / Days and Time
In this example, we are using a start date and an end date and calculating the amount of time between these different dates to display the amount of time in days as a result.
Instructions

Create or edit an existing form and navigate to the Builder tab
 Add your Date elements or Date and Time elements to the form
 Add a Calculation Element
 Add a Label for the element
 In the Calculation field, click Insert Element and select the end date element
 Add a minus sign after the element bracket
 Click Insert Element and select the start date element
 Add parentheses around the elements
 After the last parenthesis, add a divide sign ( / ) and the number 86400000 to calculate the number of days
 In the Calculation Content field, add any additional context for end users such as the word "days"
 Click the Save button in the top right corner
 Your form will now calculate the total number of days entered
Note: If you use the Date and Time element, the result will display decimal points for the number of hours.
 If needed, you can add Conditional Logic based on how many days a user has selected. In the example below, we set up a Calculation element that will charge users a specific rate if the reservation is 2 days or less. We also set up a separate calculation element that will charge users a different rate if the reservation is more than 2 days.
 The Total Reservation Cost will now reflect the user's selections
Calculate Years
In this example, we are calculating the difference in time between the current date and an entered date. This can be used to calculate a user's age.
Instructions

Create or edit an existing form and navigate to the Builder tab
 Add your Date Elements to the form
Note: If you want one of the date elements to reflect the current date, ensure the Default Date field is set to Form Viewed and toggle on Read Only.
 Add a Calculation Element
 Add a Label for the element
 Under the Calculation field, click the ROUND option
 Click inside the parentheses () and select the current date element from the Insert Element dropdown
 Add a minus sign (  ) after the element bracket }
 Click Insert Element and select the other date element
 Add a divide sign / after the parentheses
 Enter the following numbers to calculate the time in years: 31540000000, 1
Note: The 1 after the comma refers to how many decimal places you would like the calculation to display. If you do not wish to show decimal places, you can add a 0, however, the calculation will then round up to the nearest whole number. For example, instead of showing someone's age as 30.6 years, it would display as 31.  Add parentheses () to the start of the formula (after the ROUND) and to the end of the formula
Note: The example formula above is: ROUND(({ELEMENT:Current_Date}  {ELEMENT:Date_of_Birth}) / 31540000000, 1). Replace the Element names with the name of the elements in your form.  In the Calculation Content field, add any additional context for end users
 Click the Save button in the top right corner
 Your form will now calculate the total number of years
 If needed, you can add Conditional Logic based on a user's age. In the example below, we set up a Calculation element that will charge users a specific rate if they are age 55 or older. We also set up a separate calculation element that will charge users a different rate if they are younger than 55.
 The Total Registration Cost will now reflect the user's age selection
Comments
Let us know what was helpful or not helpful about the article.0 comments
Please sign in to leave a comment.