Start a conversation

Check if year is in the future

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_now) {
    "The year cannot be in the future";
} else {
    "The year is correct";
}

Test it here in the calculation helper.


Alternatively, you can use the following template and set up data validation rules based on the output 1 or 2.

var year = moment('{year_field}').format('YYYY');
var year_now = moment().format('YYYY');
if (year > year_now) {
    1;
} else {
   2;
}
Choose files or drag and drop files
Was this article helpful?
Yes
No
  1. Castor Support Team

  2. Posted