View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Fred Smith Fred Smith is offline
external usenet poster
 
Posts: 623
Default Calculate number of hours between dates and times excluding Weekends

Your requirements contradict each other. So let's deal with one at a time.

If your start date/time is in A1, and your end time is in A2, the number of
hours difference is:

=(a2-a1)*24 [format as a number]

As there are 24 hours in a day, you can also simply check to see if the
difference is more than one day.

So your if statement might look something like:

=if(a2-a11,"Exceeded","Not Exceeded")

With respect to weekends, how can you exclude weekends in the calculation, but
then need to know if you've crossed into a weekend? We need at better definition
of what you consider a weekend. For example,

-- is it a time period of 48 hours?
-- does it start at, say, 6pm on Friday?
-- does it end at, say, 8am on Monday?


--
Regards,
Fred


wrote in message
oups.com...
Hi I need to calculate the number of hours between two dates and times
excluding weekends. I would assume this requires a VB code but not too
familar with it, can anyone help.

For .e.g:

Start Date: - 23/10/06 12:30
End Date: - 25/10/06 11:30

The code should calculate if the difference is 24 hours or more and
display a message Exceeded or if it is less say not exceeded but if it
has crossed over the weekend then say, Weekend.

Can anyon please help!!!

Thanks
Princy