Printing date ranges dynamically in the emails

kumar22
Tera Contributor

Hi Team,

I have a requirement where I need to print the two dates dynamically in the notifications as below.

I want to print the Last Monday (Monday, 17 JUNE 2024) and last Sunday (Sunday, 23 JUNE 2024) from the prior week.

 

Monday, 17 JUNE 2024 - Sunday, 23 JUNE 2024.

 

Please suggest.

Thanks,

2 REPLIES 2

Rajesh Chopade1
Mega Sage

hi @kumar22 

 

You need to create the mailscript and use in your email notification.

You can utilize following sample code in your mail script to populate the days.

 

var d = new Date();
// set to Monday of this week
d.setDate(d.getDate() - (d.getDay() + 6) % 7);
// set to previous Monday
d.setDate(d.getDate() - 7);
// create new date of day before
var sunday = new Date(d.getFullYear(), d.getMonth(), d.getDate() - 1);

 

Thank you

 

Hi @Rajesh Chopade1, I tried with a script provided by you but it is printing the value as below. 

Script: Sun Jun 16 2024 00:00:00 GMT-0700 (PDT)