#1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
mbc mbc is offline
external usenet poster
 
Posts: 8
Default Adding times

I am using the following formula to add times (24 hour) in MS Excel 2003
=IF(J<I,J+1-I,J-I) . I is my start time J is my finish time. The formula
works ok when a start and finish time are entered but if ONLY a start time or
finish time are entered the "total hours" cell is populated with incorrect
data. Is there any way I can say"if either I or J are empty then "total Hours
= 0
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 8,856
Default Adding times

Try this:

=IF(OR(I="",J=""),0,IF(J<I,J+1-I,J-I))

Obviously, I and J need to be cell references (unless they are named
ranges).

Hope this helps.

Pete

"MBC" wrote in message
...
I am using the following formula to add times (24 hour) in MS Excel 2003
=IF(J<I,J+1-I,J-I) . I is my start time J is my finish time. The formula
works ok when a start and finish time are entered but if ONLY a start time
or
finish time are entered the "total hours" cell is populated with incorrect
data. Is there any way I can say"if either I or J are empty then "total
Hours
= 0



  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 4,393
Default Adding times

Let's begin by simplifying your formula to
=(J1-I1)+(J1I1)
which is functional identical to your formula. The second term evaluates to
0 or 1 but when Excel does arithmetic on Boolean values it takes FALSE as 0
and TRUE as 1

Now we can test for cells with no data (blank cells are considered to equal
zero):
=IF(OR(I1=0,J1=0),0,(J1-I1)+(J1I1))

best wishes
--
Bernard V Liengme
Microsoft Excel MVP
http://people.stfx.ca/bliengme
remove caps from email

"MBC" wrote in message
...
I am using the following formula to add times (24 hour) in MS Excel 2003
=IF(J<I,J+1-I,J-I) . I is my start time J is my finish time. The formula
works ok when a start and finish time are entered but if ONLY a start time
or
finish time are entered the "total hours" cell is populated with incorrect
data. Is there any way I can say"if either I or J are empty then "total
Hours
= 0



  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
mbc mbc is offline
external usenet poster
 
Posts: 8
Default Adding times

Thanks Bernard, that solved my initial problem. However I am trying to work
out the "shift Gap"(Rest time) between two shifts which are on different
worksheets in the same file. Worksheet 17 cell ref AB3 contains my finish
time of 17:00 and worksheet 18 cell ref I10 contains my shift start time of
8:00. The answer is 15 but the formula I am using gives me an answer of 17?.
Cant see where I am going wrong.
=IF('Week 17'!AB3=0,24,IF('Week 17'!AB3I3,('Week
17'!AB3-I3)*24,24-(I3-'Week 17'!AB3)*24))

"Bernard Liengme" wrote:

Let's begin by simplifying your formula to
=(J1-I1)+(J1I1)
which is functional identical to your formula. The second term evaluates to
0 or 1 but when Excel does arithmetic on Boolean values it takes FALSE as 0
and TRUE as 1

Now we can test for cells with no data (blank cells are considered to equal
zero):
=IF(OR(I1=0,J1=0),0,(J1-I1)+(J1I1))

best wishes
--
Bernard V Liengme
Microsoft Excel MVP
http://people.stfx.ca/bliengme
remove caps from email

"MBC" wrote in message
...
I am using the following formula to add times (24 hour) in MS Excel 2003
=IF(J<I,J+1-I,J-I) . I is my start time J is my finish time. The formula
works ok when a start and finish time are entered but if ONLY a start time
or
finish time are entered the "total hours" cell is populated with incorrect
data. Is there any way I can say"if either I or J are empty then "total
Hours
= 0




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
ADDING TIMES William Excel Worksheet Functions 3 September 29th 08 01:20 AM
Adding times Bobby New Users to Excel 3 August 6th 06 11:09 PM
adding times together changetires Excel Discussion (Misc queries) 4 June 30th 06 01:40 PM
Adding up Times Lisa Excel Worksheet Functions 2 September 1st 05 02:32 PM
Adding times Jim Excel Worksheet Functions 2 July 13th 05 03:22 AM


All times are GMT +1. The time now is 02:33 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"