SAP dynamic dates Monday-Sunday


I am automating the running of a report in SAP to run from the Monday of the current week until Sunday. This week, it needs to run with dates 03/16/2020 - 03/22/2020. Next week, it will have to run with dates 03/23/2020 - 03/29/2020, etc. How can I specify for it to run from Monday-Sunday and have it update every week with the new dates?

Thank you!

Iā€™m assuming you will want to enter these values in a text box. In that case, a string value will work well.

Create two string variables called dayMonday and daySunday. Then add two Assign activities. Use the code below.

dayMonday = Now.AddDays(-1 * ((7 + (Now.DayOfWeek - DayOfWeek.Monday)) Mod 7)).Date.ToString("MM/dd/yyyy")
daySunday = Now.AddDays(7 + (DayOfWeek.Sunday - Now.DayOfWeek) Mod 7).Date.ToString("MM/dd/yyyy")


This should get get you what you need.

1 Like