Results 1 to 4 of 4

Thread: Calculate number of work days?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2000
    Posts
    1,091

    Calculate number of work days?

    I need to be able to calculate the number of work days (no weekends) between to dates. How can I do this in ASP?

    Visual Studio 2010

  2. #2
    Member
    Join Date
    Sep 2002
    Location
    PAKISTAN
    Posts
    54
    Explain again and Give me ur todates
    Be Good Not Bad

  3. #3
    Addicted Member
    Join Date
    Jul 2002
    Location
    Grand Rapids, MI
    Posts
    166
    Do you need to account for national holidays and such as well?
    --------------------------
    Joon Lee

  4. #4
    Frenzied Member msimmons's Avatar
    Join Date
    Jul 2001
    Location
    Houston, TX
    Posts
    1,057
    K, I don't know what to tell you about holidays except to code them into this but I think this is the easiest way.

    VB Code:
    1. dim datTheDate
    2. dim datYourStartDate
    3. dim datYourEndDate
    4. dim intDayCount
    5.  
    6. datTheDate = datYourStartDate 'set up for the loop
    7.  
    8. While datTheDate <= datYourEndDate 'for every day in range
    9.  
    10.    If (weekday(datTheDate) <> 1) And (weekday(datTheDate) <> 7) 'if NOT sunday or saturday
    11.          intDayCount = intDayCount + 1
    12.    End If
    13.    
    14.    datTheDate = dateadd("d", 1, datTheDate) 'move on to the next day
    15.  
    16. Wend

    That sould do it

    Michael
    I'm off to GalahTech, hope to see you there.

    If you don't like the rules they make, refuse to play their game. -- Steve Ignorant.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width