PC Review


Reply
Thread Tools Rate Thread

Adding times

 
 
MBC
Guest
Posts: n/a
 
      6th Oct 2008
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 With Quote
 
 
 
 
Pete_UK
Guest
Posts: n/a
 
      6th Oct 2008
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" <(E-Mail Removed)> wrote in message
news:4ECBC06F-4129-4143-B758-(E-Mail Removed)...
>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 With Quote
 
Bernard Liengme
Guest
Posts: n/a
 
      6th Oct 2008
Let's begin by simplifying your formula to
=(J1-I1)+(J1>I1)
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)+(J1>I1))

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

"MBC" <(E-Mail Removed)> wrote in message
news:4ECBC06F-4129-4143-B758-(E-Mail Removed)...
>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 With Quote
 
MBC
Guest
Posts: n/a
 
      6th Oct 2008
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'!AB3>I3,('Week
17'!AB3-I3)*24,24-(I3-'Week 17'!AB3)*24))

"Bernard Liengme" wrote:

> Let's begin by simplifying your formula to
> =(J1-I1)+(J1>I1)
> 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)+(J1>I1))
>
> best wishes
> --
> Bernard V Liengme
> Microsoft Excel MVP
> http://people.stfx.ca/bliengme
> remove caps from email
>
> "MBC" <(E-Mail Removed)> wrote in message
> news:4ECBC06F-4129-4143-B758-(E-Mail Removed)...
> >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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding Times LiAD Microsoft Excel Worksheet Functions 7 10th Sep 2008 02:10 PM
ADDING TIMES John C. Harris, MPA Microsoft Excel Worksheet Functions 5 9th Aug 2005 05:32 PM
Adding times =?Utf-8?B?Smlt?= Microsoft Excel Worksheet Functions 2 13th Jul 2005 03:22 AM
Adding Times up IainG Microsoft Excel Misc 3 22nd Oct 2004 09:35 PM
adding times, again! laurieg Microsoft Excel Worksheet Functions 0 5th Jul 2003 01:14 PM


Features
 

Advertising
 

Newsgroups
 


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