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 Check time in cells to see if it goes across lunch

Hi all

Is there a way to check the time in two cells to make sure that it doesn't count a lunch break. ie

Start time is 8:45 end time is 16:25 so I need to subtract 30 minutes, however if I run an if statement
and say use 12:30 if the job starts after 12:30 it will still subtract 30 minutes which I don't want.


Also If it ends before 12:00 again no time subtraction.

Thanks all
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5,651
Default Check time in cells to see if it goes across lunch

On Sat, 09 Feb 2008 10:52:10 -0600, koob <koob@koob wrote:

Hi all

Is there a way to check the time in two cells to make sure that it doesn't count a lunch break. ie

Start time is 8:45 end time is 16:25 so I need to subtract 30 minutes, however if I run an if statement
and say use 12:30 if the job starts after 12:30 it will still subtract 30 minutes which I don't want.


Also If it ends before 12:00 again no time subtraction.

Thanks all



=End-Start-TIME(,30,)*AND(Start<TIME(12,,),EndTIME(12,30,))


--ron
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 8,651
Default Check time in cells to see if it goes across lunch

=B2-A2-TIME(0,30,0)*AND(A2<=TIME(12,30,0),B2=TIME(12,0,0 ))
--
David Biddulph

"koob" <koob@koob wrote in message
...
Hi all

Is there a way to check the time in two cells to make sure that it doesn't
count a lunch break. ie

Start time is 8:45 end time is 16:25 so I need to subtract 30 minutes,
however if I run an if statement
and say use 12:30 if the job starts after 12:30 it will still subtract 30
minutes which I don't want.


Also If it ends before 12:00 again no time subtraction.

Thanks all



  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,344
Default Check time in cells to see if it goes across lunch

Hi,

If you are looking for a general solution, as I see it there are 6
possibilities:

1. Start before 12, end after 12:30
2. Start before 12, end before 12
3. Start before 12, end during lunch (say 12:15)
4. Start after lunch, (end after lunch )
5. Start during lunch, end after lunch
6. Start during lunch, end during lunch

To cover all of these situations the formula is a little bit more
complicated, suppose your Start time is in cell A1 and your End time in B1
then:

=IF(AND(B1=TIME(12,30,),A1<=TIME(12,,)),B1-A1-TIME(,30,),IF(AND(A1=TIME(12,,),B1<=TIME(12,30,)) ,0,IF(AND(A1TIME(12,,),A1<TIME(12,30,)),B1-TIME(12,30,),IF(AND(A1<=TIME(12,,),B1TIME(12,,)), TIME(12,,)-A1,B1-A1))))

To simplify this formula:
In cell F1 enter =TIME(12,,)
In cell F2 enter =TIME(12,30,)
Name cell F1 L and name cell F2 U

Then you can use the revised version of the above formula:

=IF(AND(B1=U,A1<=L),B1-A1-TIME(,30,),IF(AND(A1=L,B1<=U),0,IF(AND(A1L,A1<U) ,B1-U,IF(AND(A1<=L,B1L),L-A1,B1-A1))))

To further simplify the formula you can determine if any of the 6 conditions
I listed would never apply and remove the appropriate portion of the formula.
For example suppose they can never start or end during lunch, then the
formula can be simplified to read:

=B1-A1-AND(A1<0.5,B112.5/24)*.5/24

In this case I have not used range names but I have eliminated the need for
the longer TIME() function.

or with the range names

=B1-A1-(AND(A1<L,B1U)*.5/24)

--
Cheers,
Shane Devenshire


"koob" wrote:

Hi all

Is there a way to check the time in two cells to make sure that it doesn't count a lunch break. ie

Start time is 8:45 end time is 16:25 so I need to subtract 30 minutes, however if I run an if statement
and say use 12:30 if the job starts after 12:30 it will still subtract 30 minutes which I don't want.


Also If it ends before 12:00 again no time subtraction.

Thanks all

  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,091
Default Check time in cells to see if it goes across lunch

How would you do this manually, on paper? When you determine that, you can
do it in Excel using the same formula.

Tyro

"koob" <koob@koob wrote in message
...
Hi all

Is there a way to check the time in two cells to make sure that it doesn't
count a lunch break. ie

Start time is 8:45 end time is 16:25 so I need to subtract 30 minutes,
however if I run an if statement
and say use 12:30 if the job starts after 12:30 it will still subtract 30
minutes which I don't want.


Also If it ends before 12:00 again no time subtraction.

Thanks all



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
Time and lunch breaks mndpy Excel Worksheet Functions 5 September 4th 07 09:54 PM
How to substract for lunch on =MOD function jcc31 Excel Worksheet Functions 4 March 9th 06 07:30 PM
Time Calculation For A Timesheet To Include Lunch poddys Excel Worksheet Functions 2 March 3rd 06 08:05 PM
Assumed Lunch Jeff Excel Discussion (Misc queries) 2 March 20th 05 05:35 AM
How can Excel do daily timesheet, -lunch time, & not use colon in. Jan Excel Worksheet Functions 2 March 8th 05 10:05 PM


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