Start a conversation

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-YYYY');
var newDate = date.subtract(1, 'months');

Test this template in the calculation helper.

If you want to use different time units, you can change the second line of the code. For example, if you want to add 2 years to your date instead of 1 month, you can use: 

var newDate = date.subtract(2, 'years');

Choose files or drag and drop files
Was this article helpful?
  1. Castor Support Team

  2. Posted
  3. Updated