Calculations with date fields

Calculations with date fields

Note: These features are part of the Visforms Subscription and are not included in the free Visforms version.

For a better understanding, we recommend reading the documentation completely and using the Section Introduction to start.
Relationships explained in earlier sections of the documentation are not repeated here.

Areas of application

The “Calculations with date fields” feature is particularly suitable for booking forms. It allows you to find the difference in days between the values selected in two different date fields. This difference can be used in subsequent calculations.

Functionality

If a date field in the form is not filled, then Visforms automatically uses the value 0 for this field.

If a date is set, it is converted into the so-called Unix time stamp. This is the number of seconds that have elapsed since 1/1/1970. From this, the time difference to 01/01/1970 is calculated in days. In order for the calculation to be correct, the time zone for calculating the Unix time stamp is first set to UTC and the time to 00:00:0.

This allows to calculate the difference in days between the values in two date fields.

Example calculation formulas

Example calculation formula for fields named “startdate” and “enddate”:

  • The 1st and last day are counted
    ([ENDDATE]-([STARTDATE])) + 1
  • Only start day or end day is counted
    ([ENDDATE]-([STARTDATE]))

Note: We recommend making all date fields to be used in calculations mandatory.

Please use the advanced control and validation options of the Visforms Subscription for date fields. This ensures that a value in the end date is always greater than a value in the start date. More on this in: Additional Options for Date Fields.