Skip to content
Advertisement

Subtract days from a Date using Script Mediator in WSO2

I want to subtract 365 days(1 year) from a Date which is in the below format using a script mediator and get the resultant Date in the same format.

JavaScript

Following is the code I’ve tried:

JavaScript

But it prints

JavaScript

Expected Date

JavaScript

Or is it possible to achieve this without using Script Mediator? What else can I try apart from using a Script Mediator?

Advertisement

Answer

If you just want to get the same date of the previous year you can do something like below.

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement