Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Working days textbox datetimepicker(calendar)

Netpayabledays textbox


Working days 31 datetimepicker(calendar) when i choose particular month that days displayed i done through coding.

Netpayabledays textbox 26( i want subracting sundays from selecting a particular month. remaining days to be displayed in netpayable days textbox.



for your understand i send the attach file
Posted
Comments
Tim Corey 9-Jul-12 14:30pm    
This question is quite unclear. We cannot understand what youw ant to do based upon this description. Instead of writing short phrases, please try to develop a paragraph that explains what you are attempting to do, what outcome you would like to see, and where you are having difficulties.

1 solution

It is unclear what you want.
But if I guess correctly, you want to calculate weekdays (workdays) in a month. You can use System.DateTime.DayOfWeek[^] property to see what day of week is a specific date.
Here you have some methods: http://stackoverflow.com/questions/1820173/calculate-the-number-of-weekdays-between-two-dates-in-c-sharp[^], you just have to change them to take only Sunday as weekend, and Saturday as weekday/workday.

Update: here i found the most elegant one: http://stackoverflow.com/questions/4022993/how-to-get-a-list-of-week-days-in-a-month[^]. With a little adaptation:

C#
public static int GetWorkdays(int year, int month)
        {
            return Enumerable.Range(1, DateTime.DaysInMonth(year, month))
                             .Select(day => new DateTime(year, month, day))
                             .Where(dt => dt.DayOfWeek != DayOfWeek.Sunday)
                             .Count();
        }
}
 
Share this answer
 
v2

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