06-06-2022 10:26 PM
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.
Solved! Go to Solution.
06-07-2022 12:31 AM
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:
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.
06-06-2022 10:54 PM
The start of the week (date) in a single line also works for me. Thanks
06-07-2022 12:31 AM
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:
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.
06-07-2022 04:56 PM
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 🙂