on 10-13-2023 8:48 AM
Hi all,
How can we calculate Previous Month from Current Date (in Story using script)?
Do we have function like ADD_MONTHS?
I use:
var cur_date = new Date(Date.now());
And I need to have variable as previous month.
Thank you.
igdulia
The below can help. There are lot of other function which you can use on current_date. Just hit ctrl space
var current_date=new Date(Date.now());
var current_month = current_date.getMonth()+1; // first month is 0
var prev_month=current_month-1;
console.log("Current Date is ");
console.log(current_date);
console.log("Current Month is ");
console.log(current_month);
console.log("Previous Month is ");
console.log(prev_month);
Output:
Nikhil
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Nikhil,
thank you, this I know, but in this case I will need write additional code to calculate it correct:
if Current_Month < 1, then ....
Current_Year = ...
Current Month = ...
Current_CalMonth =....
And if I will nedd Current_Month - 4 monthes, it will other "If ...."
Becouse of this I thought that maybe exist AddMonth function, but I didn't find.
Thank you.
User | Count |
---|---|
78 | |
9 | |
9 | |
7 | |
7 | |
6 | |
6 | |
5 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.