User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 402,503 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,746 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Dec 11th, 2007
Views: 4,079
I browsed google and found nothing so thought i would put my efforts up here.
hope this all helps.

this function will allow you to return the number of days between two dates minus saturdays and sundays. (including the start date)
Last edited : Dec 11th, 2007.
javascript Syntax
  1. // ########## startMonth and endMonth both start at 0 i.e 0 = january, 1 = feb etc
  2. function getDaysMinusWeekend(startDay, startMonth, startYear, endDay, endMonth, endYear) {
  3. var sdate = new Date();
  4. var edate = new Date();
  5. var odays = 0;
  6. var total = 0;
  7.  
  8. sdate.setFullYear(startYear,startMonth,startDay);
  9. edate.setFullYear(endYear,endMonth,endDay);
  10.  
  11. odays = 6 - sdate.getDay();
  12. if(odays == 6) {
  13. odays = 0;
  14. }
  15.  
  16. sdate.setFullYear(startYear,startMonth,startDay + odays);
  17.  
  18. return Math.floor(((((edate.getTime() - sdate.getTime()) / 1000 / 60 / 60 / 24) / 7) * 5) +
  19.  
  20. odays);
  21. }
Post Comment

Only community members can submit or comment on code snippets. You must register or log in to contribute.

DaniWeb Marketplace (Sponsored Links)
All times are GMT -4. The time now is 5:40 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC