By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
 448,820 Members | 1,547 Online
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,820 IT Pros & Developers. It's quick & easy.

count days including weekend

 P: n/a I have a routine that's calculating business days but its not counting the weekend days that are between the start date and end date. If my start date is 9/26/08 and my end date is 10/01/08, I should see 4 business days and 2 weekend days. How can I get that result? I'm getting 4 business days but its not counting the weekend days? Sep 26 '08 #1
Share this Question
7 Replies

 P: n/a On Sep 26, 8:31*am, "Mike"

 P: n/a I tried your code snippet and its not working, If I enter in "09/26/2008" and "10/01/2008" it returns 1 weekend day, it should be 2. "CSharper"

 P: n/a Can you post your code? "Mike" wrote: I have a routine that's calculating business days but its not counting the weekend days that are between the start date and end date. If my start date is 9/26/08 and my end date is 10/01/08, I should see 4 business days and 2 weekend days. How can I get that result? I'm getting 4 business days but its not counting the weekend days? Sep 26 '08 #4

 P: n/a I'm trying this which I found online some time back: public void AddWeekdays(DateTime start, int days) { try { if (start.DayOfWeek == DayOfWeek.Saturday || start.DayOfWeek == DayOfWeek.Sunday) { } else { int remainder = days % 5; int weekend = (5 / days) *2; DateTime end = start.AddDays(remainder); if (end.DayOfWeek == DayOfWeek.Saturday) { end = end.AddDays(2); } else if (end.DayOfWeek < start.DayOfWeek) { end = end.AddDays(2); } txtWDays.Value = weekend.ToString(); txtCDates.Text = end.AddDays(days + weekend - remainder).ToShortDateString(); } } catch (Exception ex) { } } "Family Tree Mike" I have a routine that's calculating business days but its not countingtheweekend days that are between the start date and end date. If my startdateis 9/26/08 and my end date is 10/01/08, I should see 4 business days and2weekend days.How can I get that result? I'm getting 4 business days but its notcountingthe weekend days? Sep 26 '08 #5

 P: n/a On Sep 26, 9:26*am, Family Tree Mike

 P: n/a On Sep 26, 9:32*am, "Mike"

 P: n/a On Sep 26, 10:23 am, "Mike"

This discussion thread is closed

Replies have been disabled for this discussion.