Me with an attendance marking application with
C#.net and sqlserver, at first I am trying to allocate shifts to each
employee in shifts I want to enter in the table all holidays for the
corresponding shift. How can I get the dates of all Sundays of the year 2009
How can I get the dates of all Sundays of the year 2009 using C#.net
Hai,
Ashley ArgilePosted Oct 3, 2008, 2:25 AM
class Program
{
static void Main(string[] args)
{
DateTime dayOfWeek = new DateTime(2009, 1, 1);
while (dayOfWeek.Year == 2009)
{
if (dayOfWeek.DayOfWeek == DayOfWeek.Sunday)
Console.WriteLine(dayOfWeek.Date.ToString("dd/MM/yyyy"));
dayOfWeek = dayOfWeek.AddDays(1.0);
}
Console.ReadKey(); // To stop the console disappearing in VS debug.
}
}
Regards
Ashley
p.s.
There's probably a more elegant way of doing this and if I think of something else I'll post it.