C# DateTime AddDays
Description
DateTime AddDays
returns a new DateTime that adds the
specified number of days to the value of this instance.
Syntax
DateTime.AddDays
has the following syntax.
public DateTime AddDays(
double value
)
Parameters
DateTime.AddDays
has the following parameters.
value
- A number of whole and fractional days. The value parameter can be negative or positive.
Returns
DateTime.AddDays
method returns An object whose value is the sum of the date and time represented by this instance
and the number of days represented by value.
Example
The following example uses the AddDays method to determine the day of the week 36 days after the current date.
using System;/*from ww w.j a v a 2s. com*/
class Class1
{
static void Main()
{
DateTime today = DateTime.Now;
DateTime answer = today.AddDays(36);
Console.WriteLine("Today: {0:dddd}", today);
Console.WriteLine("36 days from today: {0:dddd}", answer);
}
}
The code above generates the following result.