How to add days to date in c#

{0 Comments}

To add a day to existed date, we can use Adddays inbuilt function in C#. it associated with the date time data type.  Call the function after dot and pass number of the days as a parameter in the add days function. Following is the code samples to understand the use of add days function. In following olddate name Date time variable is created and current date is assign to it. Then 12 days is added to current date time and new date time after adding assign to new_datetime variable.

 C# |  copy code |? 
1
DateTime olddate=DateTime.Now;
2
DateTime new_datetime = olddate.AddDays(12); 
3

Leave a Comment

Your email address will not be published.