Click here to Skip to main content
15,893,190 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Can anyone tell me how to find Saturday and Sunday in current week
Posted
Updated 1-Dec-09 2:44am
v2

Something like this should work for you -

DateTime GetDateFromDay(DayOfWeek dayOfWeek, int searchDirection)
{
    if (Math.Abs(searchDirection) != 1)
        throw new ArgumentException("Must be 1 or -1", "searchDirection");
    DateTime testDate = DateTime.Today;
    while (testDate.DayOfWeek != dayOfWeek)
        testDate = testDate.AddDays(searchDirection);
    return testDate;

}
 
Share this answer
 
v2
This is an incredibly basic question. And it has NOTHING to do with ASP.NET. If you think it does, you need to do some basic research. Actually, either way, you need to read a basic book.

The DateTime class will tell you the day of the week for the given date, so you can use that to work out what days are on the weekend.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900