- 1. Description of the feature
- 2. In practice, how to make calculations on dates?
- 3. Retrieve date data:
It is useful to do calculations on dates if you want to automatically calculate the date of a future intervention from the data filled in by your operator. You will be able to create a formula in a Date widget.
1. Description of the feature
You can add and / or subtract days, months or years to a date.
You can then take the value of a first date, then add days, months or years.
The formulas to insert in your date widget will be:
- Days: ## tag_date ## + days (Number of days desired)
- Month: ## tag_date ## + months (Number of months desired)
- Years: ## tag_date ## + years (Number of years desired)
2. In practice, how to make calculations on dates?
Context: Imagine a company that performs interventions on escalators. After a first intervention, a second checking intervention is systematically planned. This second intervention will always take place 11 days after the first.
1. Drag and drop a first Date widget into your form.
2. Name the date date widget of the job. Tick the current date option.
3. Drag and drop a second Date widget. Name the "Verification maintenance".
4. In the options, click on "formula".
5. Copy and paste the tag of the first date widget
6. Add a "+", then the word "days" and finally "(11)". We therefore ask to add 11 days.
7. Publish your form and take the test on the mobile application.
3. Retrieve date data:
Using tags, it is possible to extract the day, month or year from a date widget. This allows you to name elements precisely.
Here are the tags with their specific features:
- ##tagdate:year## → retrieves the year of the date
- ##tagdate:month## → retrieves the month of the date
- ##tagdate:day## → retrieve the day from the date
- ##tagdate:raw## → retrieve the date without the '/' character (for example: 06052023)
3.1. Practical example
Purpose: To retrieve the "day" value from the date widget. -Drag and drop a date widget into the form.-Drag and drop a text widget.-Copy the tag of the date widget into the default value of the text widget, adding "day" before the ## at the end.-You should have a default value as follows: ##date_ThwU3MmQ:day##.