Start a conversation

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 variable name between these brackets {Variablename}

var castorDate = moment('{Variablename}','DD-MM-YYYY');
var today = moment();
var tenDaysAgo = moment().subtract(10, 'days');
if(castorDate.diff(moment()) > 0 ){
    'This date is in the future';
} else {
    if(castorDate.diff(tenDaysAgo) > 0) {
        'This date is less than 10 days ago';
    } else {
        'This date is more than 10 days ago.';
    }
}
Choose files or drag and drop files
Was this article helpful?
Yes
No
  1. Tonya

  2. Posted
  3. Updated