Get date from last week

I am trying to have variables be assigned the dates of the previous Monday and Friday so they are in this format (MM-dd-yyyy). For example if the program were to run on Tuesday Dec. 17th it would give a string as “12-09-2019” and another string as “12-13-2019”

Assign the value as DateTime.Now.AddDays(-7).ToString(“MM-dd-yyyy”)

Docs for DateTime.AddDays method: https://docs.microsoft.com/en-us/dotnet/api/system.datetime.adddays?view=netframework-4.8

Docs for DateTime.ToString method https://docs.microsoft.com/en-us/dotnet/api/system.datetime.tostring?view=netframework-4.8

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.