datetime class : AddDays(int) method

Description

Gets a new datetime instance which is obtained by adding the number of days to the invoker instance.

Syntax

datetimeInstance.AddDays(int numberOfDays)

Arguments

ClassNameDescription
intnumberOfDaysNumber of days

Return value

ClassDescription
datetimeNew datetime type instance which is obtained by adding the argument.

Sample code

1:

datetime dt = new datetime(2016, 3, 4, 4, 13, 0);

2:

datetime addDay1 = dt.AddDays(5); // 2016/3/9 4:13:00

3:

datetime addDay2 = dt.AddDays(-5); // 2016/2/28 4:13:00

Notes

It's a wrapper of the System.DateTime.AddDays(Double) method.

Links for reference

Copyright © Cooker All rights reserved.