DateTime.AddDays(Double) C# with Example



DateTime.AddDays(Double) C# with Example

Add days into a dateTime object. 
DateTime today = DateTime.Now; 
DateTime answer = today.AddDays(36); 
Console.WriteLine("Today: {0:dddd}", today); 
Console.WriteLine("36 days from today: {0:dddd}", answer); 
You also can subtract days passing a negative value: 
DateTime today = DateTime.Now; 
DateTime answer = today.AddDays(-3); 
Console.WriteLine("Today: {0:dddd}", today); 
Console.WriteLine("-3 days from today: {0:dddd}", answer); 

0 Comment's

Comment Form

Submit Comment