If I have two dates like this, I wonder how it will be possible to count how many of these days that are:
Monday,Tuesday,Wednesday,Thursday,Friday

The dates are for example:

11/01/2009
11/18/2009

Recommended Answers

All 2 Replies

Thanks, but I think but are not sure that this function counts the days if the start and enddate falls within a weekday wich is a problem:
"// This function includes the start and end date if it falls on a weekday
"
Though I found another approach to simply test each day in a loop like this and do a count wich will work fine.
Though a bit manually but should work.

DateTime dt = new DateTime(2009, 11, 27);

            if (dt.DayOfWeek == DayOfWeek.Friday)
            {
                MessageBox.Show("Found");
            }

First thing I found when googling weekdays between two dates in C# http://www.eggheadcafe.com/PrintSearchContent.asp?LINKID=1041

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.