Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. Calculate working days from two dates

Calculate working days from two dates

Scheduled Pinned Locked Moved Web Development
javascript
4 Posts 3 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    User 556471
    wrote on last edited by
    #1

    I want to calculate total working days between the two dates specified in ASP or javascript: e.g., date1 = 16/08/2005 date2 = 25/08/2005 there are two holidays in the duration specified above. Thanx

    V 1 Reply Last reply
    0
    • U User 556471

      I want to calculate total working days between the two dates specified in ASP or javascript: e.g., date1 = 16/08/2005 date2 = 25/08/2005 there are two holidays in the duration specified above. Thanx

      V Offline
      V Offline
      Vasudevan Deepak Kumar
      wrote on last edited by
      #2

      anyla, You may use DateTime.Compare to get the difference but for WorkingDays, you need to have a class which calculates the number of holidays within a date span. This again is dependent on each region and/or enterprise. Is'nt it? Vasudevan Deepak Kumar Personal Web: http://www.lavanyadeepak.tk/ I Blog At: http://deepak.blogdrive.com/

      U 1 Reply Last reply
      0
      • V Vasudevan Deepak Kumar

        anyla, You may use DateTime.Compare to get the difference but for WorkingDays, you need to have a class which calculates the number of holidays within a date span. This again is dependent on each region and/or enterprise. Is'nt it? Vasudevan Deepak Kumar Personal Web: http://www.lavanyadeepak.tk/ I Blog At: http://deepak.blogdrive.com/

        U Offline
        U Offline
        User 556471
        wrote on last edited by
        #3

        yes we can calculate the difference b/w the dates, but i need a function to calculate number of working days (from the calendar dates). and the holidays (offdays) are saturday and sunday. thanx

        G 1 Reply Last reply
        0
        • U User 556471

          yes we can calculate the difference b/w the dates, but i need a function to calculate number of working days (from the calendar dates). and the holidays (offdays) are saturday and sunday. thanx

          G Offline
          G Offline
          Guffa
          wrote on last edited by
          #4

          Here is a simple, but not very efficient, method: date1 = #2005-08-16# date2 = #2005-08-25# day = date1 days = 0 While day <= date2   wday = Weekday(day, vbMonday) ' <-- here you use the first day of week   If wday <> vbSaturday and wday <> vbSunday Then     days = days + 1   End Id   day = DateAdd("d", 1, day) Wend Response.Write "The number of workdays are: " & days --- b { font-weight: normal; }

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups