Start and end date of a week

Hi,
How to get a start and end date of a week in a single line, I need to use this in a map snap.
Thanks,
Deepak.

The start of the week (date) in a single line also works for me. Thanks

Hi @deepak.shaw

Try the following expression in a Mapper snap:

"Week start: " + Date.now().minusDays(Date.now().getDay()).toLocaleDateString() + " - Week end: " + Date.now().minusDays(Date.now().getDay()).plusDays(6).toLocaleDateString()

The output should look like this:
image

This expression gets the current week start date (Sunday), and the current week end date (Saturday), if you want to consider other days and to modify the output, try changing the expression accordingly.

Let me know if this works for you.

Best Regards,
Aleksandar.

5 Likes

Hi @AleksandarAngelevski ,
Great solution, In fact, I have implemented it like:

Date.parse(Date.parse($.get('exit_date')).plusDays(-Date.parse($.get('exit_date')).getDay())).toLocaleDateTimeString({"format":"yyy-MMM-dd"})

But your suggestion is better. Thanks, Deepak :slight_smile:

2 Likes