Skip to content

Calendar days for particular month in day

Asked Jul 9, 2012, 7:03 AM EDT2 answers
Share
LinkedInX
  
 working days textbox datetimepicker(calendar)

 when i click the datetimepicker that particular month of day will be displayed i done through coding.

 then i have net payable days  textbox if i click the particular month that month of day sundays to be subracted and remaining days to be displayed in the net payable days textbox.

for your understand

  working days  textbox datetimepicker(calendar)     net payable days  textbox   26
                              31    if i choose january 31                 26 days to be dispalyed
                                     to be dispalyed in textbox

2 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    Please corret me my understanding... basically you want to ignore all the sundays of the particular month correct.
    0
  • 0
    Define an Extension Method on DateTime like so:
    public static class DateTimeExtensions 
    { 
        public static bool IsWorkingDay(this DateTime date) 
        { 
            return date.DayOfWeek != DayOfWeek.Sunday; 
     
        } 
    } 
    Then, use is within a Where clause to filter a broader list of dates:
    var allDates = GetDates(); // method which returns a list of dates 
     
    // filter dates by working day's  
    var countOfWorkDays = allDates 
         .Where(day => day.IsWorkingDay()) 
         .Count() ; 


    http://stackoverflow.com/questions/1617049/calculate-the-number-of-business-days-between-two-dates

    http://stackoverflow.com/questions/273048/how-to-determine-the-last-business-day-in-a-given-month

    All the examples consider working days as Monday to Friday,
    so you need to change this to Monday to Saturday.

    Hope this helps you.
    0