I have a code:
int MonthNow = System.DateTime.Now.Month;
int YearNow = System.DateTime.Now.Year;
int DayNow = System.DateTime.Now.Day;
How
DateTime tomorrow = DateTime.Today.AddDays(1);
DateTime yesterday = DateTime.Today.AddDays(-1);
Today :
DateTime.Today
Tomorrow :
DateTime.Today.AddDays(1)
Yesterday :
DateTime.Today.AddDays(-1)
The trick is to use "DateTime" to manipulate dates; only use integers and strings when you need a "final result" from the date.
For example (pseudo code):
Get "DateTime tomorrow = Now + 1"
Determine date, day of week, day of month - whatever you want - of the resulting date.
Use DateTime.AddDays()
(MSDN Documentation DateTime.AddDays Method).
DateTime tomorrow = DateTime.Now.AddDays(1);
DateTime yesterday = DateTime.Now.AddDays(-1);
Beware of adding an unwanted timezone to your results, especially if the date is going to be sent out via a Web API. Use UtcNow instead, to make it timezone-less.
You want DateTime.Today.AddDays(1)
.