Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 358
Default work hours calculation Excel 2003

I am currently using the following formula to calculate work hours. However
when I do not have an end date / time it very large number is calculated

In the example below the start date is 2008/08/11 11:17 with no end date and
the calculation is 711311.22

How can I change the foluma to have a zero if no end date is completed?

IF(OR(O105<1,AND(INT(V105)=INT(O105),NOT(ISNA(MATC H(INT(V105),List!A$9:A$24,0))))),0,ABS(IF(INT(V105 )=INT(O105),ROUND(24*(O105-V105),2),
(24*(X105-W105)*
(MAX(NETWORKDAYS(V105+1,O105-1,List!A$9:A$24),0)+
INT(24*(((O105-INT(O105))-
(A105-INT(V105)))+(X105-W105))/(24*(X105-W105))))+
MOD(ROUND(((24*(O105-INT(O105)))-24*W105)+
(24*X105-(24*(V105-INT(V105)))),2),
ROUND((24*(X105-W105)),2))))))


--
Andrew
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 358
Default work hours calculation Excel 2003

I found the problem - sorted
--
Andrew


"Andrew" wrote:

I am currently using the following formula to calculate work hours. However
when I do not have an end date / time it very large number is calculated

In the example below the start date is 2008/08/11 11:17 with no end date and
the calculation is 711311.22

How can I change the foluma to have a zero if no end date is completed?

IF(OR(O105<1,AND(INT(V105)=INT(O105),NOT(ISNA(MATC H(INT(V105),List!A$9:A$24,0))))),0,ABS(IF(INT(V105 )=INT(O105),ROUND(24*(O105-V105),2),
(24*(X105-W105)*
(MAX(NETWORKDAYS(V105+1,O105-1,List!A$9:A$24),0)+
INT(24*(((O105-INT(O105))-
(A105-INT(V105)))+(X105-W105))/(24*(X105-W105))))+
MOD(ROUND(((24*(O105-INT(O105)))-24*W105)+
(24*X105-(24*(V105-INT(V105)))),2),
ROUND((24*(X105-W105)),2))))))


--
Andrew

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 108
Default work hours calculation Excel 2003

Yeah, but I already put this work into understanding that formula, so in all
decency you gotta read my answer anyway :-) --

There are a few ways to simplify this formula:

1) In the subformula
24*(((O105-INT(O105))-(A105-INT(V105)))+(X105-W105))/(24*(X105-W105)), you're
unnecessarily multiplying both terms by 24. 24xA/24xB is the same as A/B,
you see. So you can make it
((O105-INT(O105)-(A105-INT(V105))+(X105-W105))/(X105-W105).

2) Then again, if you're diving (A-B+C)/C, you can just as well make it
(A-B)/C + 1, thus making Excel calculate X105-W105 half as often:
((O105-INT(O105)-(A105-INT(V105)))/(X105-W105)+1

3) There are one or two other places where you multiply a few additive terms
by 24, where you could have added and subtracted them all and THEN multiplied
by 24, just to save work for Excel and make the formula easier for a human to
read. All in all, I get this:

IF(
OR(
O105<1,
AND(
INT(V105)=INT(O105),
NOT(ISNA(
MATCH(INT(V105),List!A$9:A$24,0)
)))),
0,
ABS(
IF(
INT(V105)=INT(O105),
ROUND((O105-V105)*24,2),
((X105-W105)*24*
(MAX(NETWORKDAYS(V105+1,O105-1,List!A$9:A$24),0)
+INT(((O105-INT(O105))-(A105-INT(V105)))/(X105-W105))+1
)
+MOD(
ROUND((O105-INT(O105)-W105+X105-(V105-INT(V105)))*24,2),
ROUND((X105-W105)*24,2)
)
)
)
)
)

Now, let's see about your question...well, you didn't say which columns are
your start and end dates (or rather timestamps), but I suppose they're W and
X, respectively. I think the solution is to have a helping column, say AA,
with the formula =IF(X105="",0,X105-W105); after that replace every
occurrence of "X105-A105" in your main formula (I see four of them) with
"AA105", like this:

IF(
OR(
O105<1,
AND(
INT(V105)=INT(O105),
NOT(ISNA(
MATCH(INT(V105),List!A$9:A$24,0)
)))),
0,
ABS(
IF(
INT(V105)=INT(O105),
ROUND((O105-V105)*24,2),
(AA105*24*
(MAX(NETWORKDAYS(V105+1,O105-1,List!A$9:A$24),0)
+INT(((O105-INT(O105))-(A105-INT(V105)))/AA105)+1
)
+MOD(
ROUND((O105-INT(O105)+AA105-(V105-INT(V105)))*24,2),
ROUND(AA105*24,2)
)
)
)
)
)

That way it calculates the days worked today (or wherever a day still isn't
finished) as 0 time put in. Although if you wanted to you could make it show
the hours put in SO FAR, ie =IF(X105="",NOW(),X105)-W105.

A few other helping columns wouldn't hurt, either. If AB105 were set to
O105-INT(O105), and perhaps AC105 to INT(V105), and AD105 to AC105=INT(O105),
you could have

IF(
OR(
O105<1,
AND(
AD105,
NOT(ISNA(
MATCH(AC105,List!A$9:A$24,0)
)))),
0,
ABS(
IF(
AD105,
ROUND((O105-V105)*24,2),
(AA105*24*
(MAX(NETWORKDAYS(V105+1,O105-1,List!A$9:A$24),0)
+INT((AB105-(A105-AC105))/AA105)+1
)
+MOD(
ROUND((AB105+AA105-(V105-AC105))*24,2),
ROUND(AA105*24,2)
)
)
)
)
)

....which is still tolerably complex but at least better.

--- "Andrew" wrote:
I found the problem - sorted

"Andrew" wrote:
I am currently using the following formula to calculate work hours. However
when I do not have an end date / time it very large number is calculated

In the example below the start date is 2008/08/11 11:17 with no end date and
the calculation is 711311.22

How can I change the foluma to have a zero if no end date is completed?

IF(OR(O105<1,AND(INT(V105)=INT(O105),NOT(ISNA(MATC H(INT(V105),List!
A$9:A$24,0))))),0,ABS(IF(INT(V105)=INT(O105),ROUND (24*(O105-V105),2),
(24*(X105-W105)*
(MAX(NETWORKDAYS(V105+1,O105-1,List!A$9:A$24),0)+
INT(24*(((O105-INT(O105))-
(A105-INT(V105)))+(X105-W105))/(24*(X105-W105))))+
MOD(ROUND(((24*(O105-INT(O105)))-24*W105)+
(24*X105-(24*(V105-INT(V105)))),2),
ROUND((24*(X105-W105)),2))))))

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
Determining work hours between dates / hours Andrew Excel Worksheet Functions 3 July 30th 08 06:38 PM
daily work schedule hours calculation leejb Excel Discussion (Misc queries) 2 June 21st 07 08:01 PM
Work hours calculation albertmb Excel Discussion (Misc queries) 3 February 28th 07 07:40 PM
Excel calculation of duration in hours and minutes [email protected] Excel Worksheet Functions 4 February 9th 07 04:25 PM
Removing non Work Hours from Excel calculation [email protected] Excel Worksheet Functions 23 March 11th 06 01:31 AM


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

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

About Us

"It's about Microsoft Excel"