Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Finding the the amount of hours between dates ex weekends

Status
Not open for further replies.

krayner79

Programmer
Jan 27, 2005
1
BM
I need to find out hwo to calculate the number of hours between to dates and their times, but i must be able to remove weekends. For instance a job started on Sunday cannot be considered to be a core in my total hours. I needa way to separate the weekends OUT.
 
krayner79,

I found this awhile back, it may work...

Code:
' Coded not TESTED
Dim dtStart, dtOutDate, noBusinessDays
 dtStart=Date 'get system date
 dtOutDate=Request.Form("your_input_date")
 noBusinessDays=datediff(d, dtStart, dtOutDate)-(datediff(ww, dtStart, dtOutDate)*2)
'calculate hours as needed

Also look here for more...

Dates

Let me know

[thumbsup2]

 
krayner79,

Darn, one other that may work...

Code:
'Number of days excluding..

' The +1 because you are including the first day. 
' For example 21st - 21st = 1day

WorkingDays: IIf(Weekday(StartDate) > Weekday(EndDate),1+Int((EndDate-StartDate)/7),Int((EndDate-StartDate)/7))*5 + Weekday(EndDate) - Weekday(StartDate) +1


..
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top