Calculation fields in Castor are often used to build advanced date validations. In Castor dates are stored as string (text) in the format 'DD-MM-YYYY'. It is generally necessary to indicate this in yo...
You can use Moment.js to compare two or three dates with each other. You can use this to build advanced dependencies or calculations. How to start More information about how to create a Moment.js obj...
1. Create a calculation field after two date fields. You can choose the variable names yourself, but you will have to change them in the calculation template in step 2. 2. Use this formula for the cal...
If you want to give a message when the date is more than X days before today, or in the future, you can use this formula. In this example 10 days or more are used as the limit. You can enter your var...
If you want to add hours and minutes to a date & time field, you can use this template. For this calculation, you will need a date & time field and a time field which are called 'datetime' and 'add_ti...
Use this template to add a month to a date, e.g. if the next visit has to be within a month after the first visit. Replace {date} with your own variable name. var date = moment('{date}', 'DD-MM-YYYY'...
See here how you can add a month to a date: Add a month to a date. Use this template to subtract a month from a date. Replace {date} with your own variable name. var date = moment('{date}', 'DD-MM-YYY...
To add hours or minutes to the time entered into a time field, you can use the following calculation template. For example, use this template to add 15 minutes: var addHours = moment('{your_time_varia...
If you want to extract a part of a date and time field (i.e. the date only, or the time only), you can use the following templates. Replace {your_datetime_variable} with your own variable name. To ext...
To validate whether a year is in the future you can use the following calculation template: var year = moment('{year_field}').format('YYYY'); var year_now = moment().format('YYYY'); if (year > year_no...