Start a conversation

Calculations with date and time

  • Doing date (and time) calculations: the basics

    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...

  • Using if/else logic with dates

    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...

  • Check if a date is before another date and show an error if so

    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...

  • Show a message when the date is more than X days before today or in the future

    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...

  • Add hours and minutes to a datetime field

    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...

  • Add a month to a date

    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'...

  • Subtract a month from a date

    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...