Printing date ranges dynamically in the emails
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2024 02:16 AM
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,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2024 04:21 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-24-2024 07:15 AM
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)