Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 93
Default Elapsed Time

I have a form with text boxes for input of the Start Date (and Time)
and End Date (and Time) for events and it calculates the total elapsed
time using the formula below which came from Chip Pearson's Excel
site.
When, for example, StartDt = 01/06/2006 15:00, EndDt = 01/10/2006
15:00, DayStart = 7:00, DayEnd = 23:00
The code behind the form writes the above data and the following
formula to the sheet.
ActiveCell.Offset(0, 5).Formula =
"=IF(AND(INT(StartDt)=INT(EndDt),NOT(ISNA(MATCH(IN T(StartDt),Holidays,0)))),0,ABS(IF(INT(StartDt)=IN T(EndDt),ROUND(24*(EndDt-StartDt),2),(24*(DayEnd-DayStart)*(MAX(NETWORKDAYS(StartDt+1,EndDt-1,Holidays),0)+INT(24*(((EndDt-INT(EndDt))-(StartDt-INT(StartDt)))+(DayEnd-DayStart))/(24*(DayEnd-DayStart))))+MOD(ROUND(((24*(EndDt-INT(EndDt)))-24*DayStart)+(24*DayEnd-(24*(StartDt-INT(StartDt)))),2),ROUND((24*(DayEnd-DayStart)),2))))))
"

I get the correct result of 32.00 hours in this case.

I was wondering, since the formula clearly recognizes that the hours
come from three different days, if the result could be parsed using VBA
to look like:

01/06/2006 3:00 PM - 11:00 PM 8.00 hours
01/09/2006 7:00 AM - 11:00 PM 16.00 hours
01/10/2006 7:00 AM - 3:00 PM 8.00 hours

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Elapsed Time

It basically subtracts the start date and time from the end date and time
and subtracts out holidays and weekends. It doesn't return an array of
times by day, so the answer would be no, there is no inherent (to the
formula) way to do that. That isn't to imply that you couldn't write
different formulas to do it.

--
Regards,
Tom Ogilvy


"John Pierce" wrote in message
oups.com...
I have a form with text boxes for input of the Start Date (and Time)
and End Date (and Time) for events and it calculates the total elapsed
time using the formula below which came from Chip Pearson's Excel
site.
When, for example, StartDt = 01/06/2006 15:00, EndDt = 01/10/2006
15:00, DayStart = 7:00, DayEnd = 23:00
The code behind the form writes the above data and the following
formula to the sheet.
ActiveCell.Offset(0, 5).Formula =

"=IF(AND(INT(StartDt)=INT(EndDt),NOT(ISNA(MATCH(IN T(StartDt),Holidays,0)))),
0,ABS(IF(INT(StartDt)=INT(EndDt),ROUND(24*(EndDt-StartDt),2),(24*(DayEnd-Day
Start)*(MAX(NETWORKDAYS(StartDt+1,EndDt-1,Holidays),0)+INT(24*(((EndDt-INT(E
ndDt))-(StartDt-INT(StartDt)))+(DayEnd-DayStart))/(24*(DayEnd-DayStart))))+M
OD(ROUND(((24*(EndDt-INT(EndDt)))-24*DayStart)+(24*DayEnd-(24*(StartDt-INT(S
tartDt)))),2),ROUND((24*(DayEnd-DayStart)),2))))))
"

I get the correct result of 32.00 hours in this case.

I was wondering, since the formula clearly recognizes that the hours
come from three different days, if the result could be parsed using VBA
to look like:

01/06/2006 3:00 PM - 11:00 PM 8.00 hours
01/09/2006 7:00 AM - 11:00 PM 16.00 hours
01/10/2006 7:00 AM - 3:00 PM 8.00 hours



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Elapsed Time KevinT Excel Worksheet Functions 9 July 2nd 08 08:27 AM
Calculate Ending time using Start Time and Elapsed Time Chief 711 Excel Worksheet Functions 5 May 13th 08 04:34 PM
Elapsed time LtFass Excel Discussion (Misc queries) 3 November 10th 07 11:45 PM
elapsed time Sweetpea60 Excel Worksheet Functions 6 March 2nd 05 04:41 PM
Elapsed time relux Excel Discussion (Misc queries) 1 February 16th 05 09:47 PM


All times are GMT +1. The time now is 02:02 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"