Search This Blog

Tuesday, April 8, 2014

Check if a date is weekend day C#

C# > System Namespace > DateTimeDayOfWeek

The DayOfWeek enumeration represents the day of the week.
Its value ranges from zero (DayOfWeek.Sunday) to six (DayOfWeek.Saturday).

Example: Check if a date is weekend day

DateTime date1 = DateTime.Now;
           
if ((date1.DayOfWeek == DayOfWeek.Saturday ||  date1.DayOfWeek == DayOfWeek.Sunday ))
{
  // action

}