Get yesterday’s date using C# is easy. All you have to do is to use the function
.AddDays to add -1 day so it returns the date of the previous day, which is yesterday.
More like this:
- Shutdown and Restart a Computer using C# Managed Code
- How to Start, Restart, and Stop a Windows Service in C#
How to get yesterday’s date in C#
DateTime yesterday = DateTime.Today.AddDays(-1); // Today is 09/24/2021