Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3
Default time and if statements

Working on a time sheet I need to deduct cell(a1)- start time from cell(b1) -
end time plus another 30 minutes - lunch time (TIME(0,30,0)? But I need
nested if statements also as in:

if (endTime - startTime <4hrs, endTime - startTime,if(endTime -
startTime4hrs, (endTime - startTime) - 30mins, if((endTime - startTime) -
30mins8hrs, 8hrs)))

This might not appear to make sense but it does because surplus hours will
be in another cell to be calculated at a different rate.

I have been doing this just with numbers, but it gets awkward taking away
the 30 minutes as in ((16.30 - 08.00)-0.30) = 8, (correct),but, ((16:30 -
08.30)-0.30) = 7.7 (because it's time represented by a number it should be
7.5, or if time 7.30)

There must be a simple way round this isn't there?
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,345
Default time and if statements

Crazy Lady,

Working with times can become involved but for your example with Start time
in B2 and finish time in C2 try:

=IF(C2="","",MIN(C2-B2-0.5/24*(C2-B24/24),8/24))

You may find it better to have a column for luch time and sutract that so
that it is clear when a meal break is included.

note that dividing the number of hours 0.5, 4 or 8 by 24 gives the decimal
equivalent to the time.

--
HTH

Sandy
In Perth, the ancient capital of Scotland
and the crowning place of kings


with @tiscali.co.uk


"Crazy Lady" wrote in message
...
Working on a time sheet I need to deduct cell(a1)- start time from
cell(b1) -
end time plus another 30 minutes - lunch time (TIME(0,30,0)? But I need
nested if statements also as in:

if (endTime - startTime <4hrs, endTime - startTime,if(endTime -
startTime4hrs, (endTime - startTime) - 30mins, if((endTime - startTime) -
30mins8hrs, 8hrs)))

This might not appear to make sense but it does because surplus hours will
be in another cell to be calculated at a different rate.

I have been doing this just with numbers, but it gets awkward taking away
the 30 minutes as in ((16.30 - 08.00)-0.30) = 8, (correct),but, ((16:30 -
08.30)-0.30) = 7.7 (because it's time represented by a number it should be
7.5, or if time 7.30)

There must be a simple way round this isn't there?



  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3
Default time and if statements

Thanks Sandy, I'll try this, but I'll have to find a new start to my formula
because I forgot to mention that it starts with "if istext(cell)" because
sometimes the cell might contain 'hol' or 'sick'. I may be able to work it
with "if isnumber".

Cheers

"Sandy Mann" wrote:

Crazy Lady,

Working with times can become involved but for your example with Start time
in B2 and finish time in C2 try:

=IF(C2="","",MIN(C2-B2-0.5/24*(C2-B24/24),8/24))

You may find it better to have a column for luch time and sutract that so
that it is clear when a meal break is included.

note that dividing the number of hours 0.5, 4 or 8 by 24 gives the decimal
equivalent to the time.

--
HTH

Sandy
In Perth, the ancient capital of Scotland
and the crowning place of kings


with @tiscali.co.uk


"Crazy Lady" wrote in message
...
Working on a time sheet I need to deduct cell(a1)- start time from
cell(b1) -
end time plus another 30 minutes - lunch time (TIME(0,30,0)? But I need
nested if statements also as in:

if (endTime - startTime <4hrs, endTime - startTime,if(endTime -
startTime4hrs, (endTime - startTime) - 30mins, if((endTime - startTime) -
30mins8hrs, 8hrs)))

This might not appear to make sense but it does because surplus hours will
be in another cell to be calculated at a different rate.

I have been doing this just with numbers, but it gets awkward taking away
the 30 minutes as in ((16.30 - 08.00)-0.30) = 8, (correct),but, ((16:30 -
08.30)-0.30) = 7.7 (because it's time represented by a number it should be
7.5, or if time 7.30)

There must be a simple way round this isn't there?




  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 620
Default time and if statements

Don't use 16.30, it should be 16:30.

If you've got 16:30 in A1, 08:30 in A2, then =((A1 - A2) - TIME(0,30,0))
will give you 07:30. Divide it by 24 and format as General will give 7.5.
--
David Biddulph

"Crazy Lady" wrote in message
...
Working on a time sheet I need to deduct cell(a1)- start time from
cell(b1) -
end time plus another 30 minutes - lunch time (TIME(0,30,0)? But I need
nested if statements also as in:

if (endTime - startTime <4hrs, endTime - startTime,if(endTime -
startTime4hrs, (endTime - startTime) - 30mins, if((endTime - startTime) -
30mins8hrs, 8hrs)))

This might not appear to make sense but it does because surplus hours will
be in another cell to be calculated at a different rate.

I have been doing this just with numbers, but it gets awkward taking away
the 30 minutes as in ((16.30 - 08.00)-0.30) = 8, (correct),but, ((16:30 -
08.30)-0.30) = 7.7 (because it's time represented by a number it should be
7.5, or if time 7.30)

There must be a simple way round this isn't there?



  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3
Default time and if statements

Hi David,

I had tried that format and it partly worked except when I started nesting
the if statements (particularly the last one). However, I didn't know about
the divide by 24 and format as general. I'll try that, thanks

Sue

"David Biddulph" wrote:

Don't use 16.30, it should be 16:30.

If you've got 16:30 in A1, 08:30 in A2, then =((A1 - A2) - TIME(0,30,0))
will give you 07:30. Divide it by 24 and format as General will give 7.5.
--
David Biddulph

"Crazy Lady" wrote in message
...
Working on a time sheet I need to deduct cell(a1)- start time from
cell(b1) -
end time plus another 30 minutes - lunch time (TIME(0,30,0)? But I need
nested if statements also as in:

if (endTime - startTime <4hrs, endTime - startTime,if(endTime -
startTime4hrs, (endTime - startTime) - 30mins, if((endTime - startTime) -
30mins8hrs, 8hrs)))

This might not appear to make sense but it does because surplus hours will
be in another cell to be calculated at a different rate.

I have been doing this just with numbers, but it gets awkward taking away
the 30 minutes as in ((16.30 - 08.00)-0.30) = 8, (correct),but, ((16:30 -
08.30)-0.30) = 7.7 (because it's time represented by a number it should be
7.5, or if time 7.30)

There must be a simple way round this isn't there?






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
Hot key for time? Dave in Des Moines New Users to Excel 2 March 24th 06 04:31 PM
Hot key for time? Dave in Des Moines Excel Worksheet Functions 2 March 24th 06 04:15 PM
Hot key for time? Dave in Des Moines Excel Discussion (Misc queries) 1 March 24th 06 03:46 PM
time sheet to calculate 2 different columns John Sullivan Excel Worksheet Functions 1 October 21st 05 06:48 AM
Using "IF" and "AND" statements with current time Bill Excel Worksheet Functions 3 April 18th 05 08:21 PM


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

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"