Adds a specified number of whole and fractional days to the current DateTimeOffset object.
using System;
public class DateArithmetic
{
public static void Main()
{
DateTimeOffset workDay = new DateTimeOffset(2008, 3, 1, 9, 0, 0, DateTimeOffset.Now.Offset);
int month = workDay.Month;
if (workDay.DayOfWeek != DayOfWeek.Monday)
{
if (workDay.DayOfWeek == DayOfWeek.Sunday)
workDay = workDay.AddDays(1);
else
workDay = workDay.AddDays(8 - (int)workDay.DayOfWeek);
}
Console.WriteLine("Beginning of Work Week In {0:MMMM} {0:yyyy}:", workDay);
}
}
Related examples in the same category