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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calculating working hours in ASP

Status
Not open for further replies.

thehead

Technical User
Jan 10, 2002
13
GB
Hi,

Just wondering if I could plead for your help :p. I need to create a webpage that calculates the number of hours a project has been worked on from 08:00 to 18:00 every date. The function would be passed a start date and an end date and would need to calculate the number of hours that passed between those dates excluding out of work hours, weekends and bank holidays. Anyone know how I could achieve this? The information would be coming from a SQL database so I don't know if it is easy to do it in the ASP code or the SQL statement what do you guy recommend?

Tom.

Webmaster of The EPICentre and owner of Minatures Online. (10% off all VOID goods!)
 
Step 1:

Create an array of all holidays that you want to exclude (bank holidays etc).

Step 2:

Create a function that allows you to pass a start date and end date.

Step 3:

For start date to end date;

create a counter (intcounter). use datediff to add 1 day, check that date isn't in the array or is a sat or sun (you can use the weekday function to find the day number) - if it is don't do anything - and add 1 to the counter (i.e. intcounter = intcounter + 1).

Step 4

Multiply intcounter by the number of hours worked in a day (you have set it as 10)


Hope this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top