Skip to content

AddDays

Adds a specified number of days to a DateTimeOffset value and returns the next valid date and time according to the calendar rules.

1
myCalendar.AddDays(dateTime: DateTimeOffset, days: number):DateTimeOffset

Parameters

DateTimeOffset dateTime
    The base DateTimeOffset value.

number days
    The number of days to add.

Returns

A new DateTimeOffset value with the added days, adjusted to the next valid date and time according to calendar rules.

Remarks

This method adds days to the specified date parameter and returns the next valid date based on calendar rules. If you want to add days by validating each day against calendar rules, please use the Calendar.AddTimeSpan method. (Ex: $Calendar.AddTimeSpan("4.00:00:00"))

Example

1
var newDate = $Calendar.AddDays($Calendar.Today, 2); //adds 2 days to the current date and returns DateTimeOffset object.

See Also