Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old September 28th, 2004, 11:41 PM
Registered User
 
Join Date: Sep 2004
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to calculate the work days beetwen two dates.

Hi,

I need to calculate the difference beetwen two dates, without the weekend (Saturday and Sunday) to display only the "Work" days.

For example:

Date 1: 29/09/2004
Date 2: 05/10/2004
Work days: 5 days

Anybody knows how to do this?

Thanks.

Reply With Quote
  #2 (permalink)  
Old October 7th, 2004, 06:23 AM
Friend of Wrox
 
Join Date: Oct 2003
Location: Chennai, TamilNadu, India.
Posts: 326
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to Santhi Send a message via MSN to Santhi
Default

Here is the code...

function DayCount()
{
   var d1 = new Date(2004,09,29);
   var d2 = new Date(2004,10,05);
   var flag=true;
   var day,daycount=0;
   while(flag)
   {
      day=d1.getDay();
      if(day != 0 && day != 6)
         daycount++;
      d1.setDate(d1.getDate()+1) ;
      if(d1.getDate() == d2.getDate() &&
                  d1.getMonth()== d2.getMonth())
      {
          flag=false;
      }
 }
document.write("Work Day COunt"+daycount);
}

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need to query dates after 90 days old melkin SQL Language 9 October 30th, 2007 08:03 AM
Calculate # of work days ? kscase SQL Server 2005 3 June 9th, 2007 09:11 PM
How to calculate a number of days between 2 date windy417 Pro JSP 1 July 20th, 2006 07:09 PM
Calculating number of days between multiple dates Vann Access 4 December 3rd, 2004 08:26 PM
Calculate Business Days - MS access 97 snoopy92211 Access VBA 0 October 13th, 2004 02:13 PM



All times are GMT -4. The time now is 11:00 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.