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_UP(({ELEMENT:End_Time}  {ELEMENT:Start_Time) / 3600000)

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

Years: divide by 31540000000
 Example Formula: ROUND_DOWN(({ELEMENT:Current_Date}  {ELEMENT:Date_of_Birth}) / 31540000000)
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, select a Rounding option
 ROUND: Will round the result to the specified number of decimal places
 ROUND_UP: Will round up the result to the nearest whole number
 ROUND_DOWN: Will round down the result to the nearest whole number
 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 number to calculate the time in hours: 3600000
Note: If you are using the ROUND function, you will need to add a comma and how many decimal places you would like the calculation to display. For example, 3600000, 2 will show two decimal places. If you do not want to show decimal places, we recommend using the ROUND_UP or ROUND_DOWN functions to round to the nearest whole number.  Add parentheses to the start of the formula (after the rounding option) 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.
You can use the ROUND_UP or ROUND_DOWN functions to round the result to the nearest whole number.
 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, select a Rounding option
 ROUND: Will round the result to the specified number of decimal places
 ROUND_UP: Will round up the result to the nearest whole number
 ROUND_DOWN: Will round down the result to the nearest whole number
 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
Note: If you are using the ROUND function, you will need to add a comma and how many decimal places you would like the calculation to display. For example, 31540000000, 1 will show one decimal place. If you do not want to show decimal places, we recommend using the ROUND_UP or ROUND_DOWN functions to round to the nearest whole number. For example, instead of showing someone's age as 30.6 years, it would display as 31 or 30.  Add parentheses () to the start of the formula (after the rounding option) and to the end of the formula
Note: The example formula above is: ROUND_DOWN(({ELEMENT:Current_Date}  {ELEMENT:Date_of_Birth}) / 31540000000). 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.