Previous working day

I want to open a file ebveryday which has name containing previous date.
The command i use is now.AddDays(-1).ToString(“dd/mm/yy”). But this dont work on monday. I want to open the file having friday’s date in it not monday. how can i do that?

@AditiGandhi You can check if today’s Day is Monday and Change to AddDays(-3), if it is Monday


use that statement within a while loop - condition will be if date is not Saturday or Sunday
i.e. NOT PreviousDate.DayOfWeek.ToString.ToLower = “saturday” ANDALSO NOT PreviousDate.DayOfWeek.ToString.ToLower = “sunday”

this can also be used for Bank Holidays if required

1 Like

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