addDays: adding days to today’s date

You can use the addDays function, if a number of days should be automatically added to today’s date.

In order to make use of this, you can include two value assignments at, for example, the beginning of the survey: one to determine today’s date and one to calculate a date further in the future, e.g. +28. Of course, it can also be about a date back in time, e.g. -7.

The following data should be defined at the first value assignment:

  • The name for the custom survey variable (e.g. Date_Today) with the value Date as data type.
  • The function for displaying today’s date, i.e. today(). This function can be specified in the box under Is equal to the following term:.
  • The option Every time the participant passes this point must have been selected at the Execute setting.

You can now create the second value assignment. It can be inserted directly below the first value assignment.

The following data should be defined at the second value assignment:

  • The name for the custom survey variable (e.g. Date_in_4_weeks) with the value Date as data type.
  • The function for calculating a date in the future, based on today’s date. For example, you want the program to calculate the date about 4 weeks from now. To do this, you must enter the formula addDays(today(),28) in the box under Is equal to the following term:. In this case, 28 days are automatically added to today’s date.
  • The option Every time the participant passes this point must have been selected at the Execute setting.

If you want to present a participant with both today’s date and the calculated date in the future, you can include a text block in the survey after both value assignments.

You can use this text block to include, for example, two lines:

  • line 1 with text like Today it is PLUS the custom variable placeholder for today’s date;
  • line 2 with text like In four weeks, it will then be PLUS the custom variable placeholder for the calculated date in the future.

These placeholders are always provided with the prefix custom, e.g. {{custom.Date_Today}}. For a description of the procedure related to including a placeholder in a text box, please consult the article Rich Text Editor (RTE).

Updated on August 21, 2023

Was this article helpful?

Related Articles

Need Support?
Please login to your Survalyzer account and use the "Create Support Request" form.
Login to Survalyzer