Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
HappyTrucker
 
Posts: n/a
Default How can I work out how many hours I get premium rate?


Hi, this is my first post here, so be gentle :)

I use a spreadsheet to track my working time. The way our wages are
calculated alter, depending on the time of day. The basic hourly rate
is incremented slightly as you go into 'unsociable hours'. I have the
following formula for working out how many hours attract a premium
after 10pm, based on starting mid afternoon:

=IF(B6="","",(IF(B6<=(LEFT(B5,5)+"22:00:00"),1-1,((((B6-(LEFT(B5,5)+"22:00:00"))-INT(B6-(LEFT(B5,5)+"22:00:00"))))*24)-0.75)))

This is broken down as follows:

If 'Finish Time (B6)' is blank, be blank, if 'Finish Time (B6)' is less
than or equal to 'Start Date (B5 left hand 5 characters) + 22:00' then
be '0'. Otherwise, work out how many hours I worked after 10pm, less
the unpaid meal break. Hope that makes sense.

Now, I've moved to night shifts and am having difficulty transforming
the code to cover this. We attract a premium rate between the hours of
10pm and 6am, so I am trying to modify it to show me how many hours I
worked between these times.

As an example: I start work at 22:00 and work until 08:00. This is a 10
hour shift, but only the hours up to 6am count for the formula. So the
number I need would be 8 (10pm til 6am). If my shift is 9pm til 8am
then this is an 11 hour shift, and the figure I need would be 8 again.
If I start at 11pm, the figure I am looking for would be 7 (11pm until
6am = 7 hours).

I've tried a couple of mutations but I keep either getting it working
out everything up to 6am, whether the shift started before 10pm or not,
or always coming up with 8.00.

I'm aiming for a formula that gives:

If Finish Time is blank, be blank, If Start Time is after or equal to
10pm AND finish time is after 6am then what is 6am minus Start Time, or
if Start Time is after or equal to 10pm and Finish Time is before or
equal to 6am what is Finish Time - Start Time, if Start Time is before
10pm and Finish Time is before 6am what is Finish Time - 10pm,
otherwise all other options equate to 6am - 10pm = 8hours.

If it helps, the start and finish times are entered as dd/mm/yyyy hh:mm
and formatted to display hh:mm

Any help will be appreciated - it's driving me scatty now :(


--
HappyTrucker
------------------------------------------------------------------------
HappyTrucker's Profile: http://www.excelforum.com/member.php...o&userid=25997
View this thread: http://www.excelforum.com/showthread...hreadid=393601

  #2   Report Post  
HappyTrucker
 
Posts: n/a
Default


OK, I think I've sorted it. Well it seems to work anyway. I don't know
whether I stumped you all, or it just wasn't clear enough. Or maybe the
problem wasn't interesting enough. Anyway, if anyone's interested,
here's what I came up with eventually. And my God is it a loooong one:

=IF(B15="","",IF(AND((B14<(LEFT(B14,5)+"22:00")),( B15<=(LEFT(B15,5)+"06:00"))),((B15-(LEFT(B14,5)+"22:00"))*24),IF(AND((B14=(LEFT(B14, 5)+"22:00")),
(B15<=(LEFT(B15,5)+"06:00"))),(B15-B14)*24,IF(AND((B14(LEFT(B14,5)+"22:00")),(B15=( LEFT(B15,5)+"06:00"))),(((LEFT(B15,5)+"06:00")-B14)*24),8))))




--
HappyTrucker
------------------------------------------------------------------------
HappyTrucker's Profile: http://www.excelforum.com/member.php...o&userid=25997
View this thread: http://www.excelforum.com/showthread...hreadid=393601

  #3   Report Post  
Biff
 
Posts: n/a
Default

Hi!

Slightly shorter....

A1 = Date/Time in
B1 = Date/Time out

=IF(B1="","",IF(MOD(A1,1)<MOD(B1,1),MIN(MIN(MOD(B1 ,1),6/24)-MOD(A1,1),6/24),IF(MOD(A1,1)<22/24,2/24+MIN(MOD(B1,1),6/24),1-MOD(A1,1)+MIN(MOD(B1,1),6/24)))*24)

Note: Discovered rounding discrepancies during testing but they do not
effect the correctness of the results. For example:

A1 = 8/7/2005 10:00 PM

=MOD(A1,1) = 0.91666666666424100000

The time value: 10:00 PM is equivalent to 22/24 as used in the formula.
However:

22/24 = 0.91666666666666700000

Biff

"HappyTrucker"
wrote in message
...

OK, I think I've sorted it. Well it seems to work anyway. I don't know
whether I stumped you all, or it just wasn't clear enough. Or maybe the
problem wasn't interesting enough. Anyway, if anyone's interested,
here's what I came up with eventually. And my God is it a loooong one:

=IF(B15="","",IF(AND((B14<(LEFT(B14,5)+"22:00")),( B15<=(LEFT(B15,5)+"06:00"))),((B15-(LEFT(B14,5)+"22:00"))*24),IF(AND((B14=(LEFT(B14, 5)+"22:00")),
(B15<=(LEFT(B15,5)+"06:00"))),(B15-B14)*24,IF(AND((B14(LEFT(B14,5)+"22:00")),(B15=( LEFT(B15,5)+"06:00"))),(((LEFT(B15,5)+"06:00")-B14)*24),8))))




--
HappyTrucker
------------------------------------------------------------------------
HappyTrucker's Profile:
http://www.excelforum.com/member.php...o&userid=25997
View this thread: http://www.excelforum.com/showthread...hreadid=393601



  #4   Report Post  
Biff
 
Posts: n/a
Default

Also note:

Not reliable if the time span is greater than 24 hrs.

Biff

"Biff" wrote in message
...
Hi!

Slightly shorter....

A1 = Date/Time in
B1 = Date/Time out

=IF(B1="","",IF(MOD(A1,1)<MOD(B1,1),MIN(MIN(MOD(B1 ,1),6/24)-MOD(A1,1),6/24),IF(MOD(A1,1)<22/24,2/24+MIN(MOD(B1,1),6/24),1-MOD(A1,1)+MIN(MOD(B1,1),6/24)))*24)

Note: Discovered rounding discrepancies during testing but they do not
effect the correctness of the results. For example:

A1 = 8/7/2005 10:00 PM

=MOD(A1,1) = 0.91666666666424100000

The time value: 10:00 PM is equivalent to 22/24 as used in the formula.
However:

22/24 = 0.91666666666666700000

Biff

"HappyTrucker"
wrote in message
...

OK, I think I've sorted it. Well it seems to work anyway. I don't know
whether I stumped you all, or it just wasn't clear enough. Or maybe the
problem wasn't interesting enough. Anyway, if anyone's interested,
here's what I came up with eventually. And my God is it a loooong one:

=IF(B15="","",IF(AND((B14<(LEFT(B14,5)+"22:00")),( B15<=(LEFT(B15,5)+"06:00"))),((B15-(LEFT(B14,5)+"22:00"))*24),IF(AND((B14=(LEFT(B14, 5)+"22:00")),
(B15<=(LEFT(B15,5)+"06:00"))),(B15-B14)*24,IF(AND((B14(LEFT(B14,5)+"22:00")),(B15=( LEFT(B15,5)+"06:00"))),(((LEFT(B15,5)+"06:00")-B14)*24),8))))




--
HappyTrucker
------------------------------------------------------------------------
HappyTrucker's Profile:
http://www.excelforum.com/member.php...o&userid=25997
View this thread:
http://www.excelforum.com/showthread...hreadid=393601





  #5   Report Post  
Biff
 
Posts: n/a
Default

Discovered a bug.....

Try this:

=IF(B1="","",IF(DAY(B1)=DAY(A1),MOD(B1,1)-MAX(MOD(A1,1),22/24),IF(MOD(A1,1)<MOD(B1,1),MIN(MIN(MOD(B1,1),6/24)-MOD(A1,1),6/24),IF(MOD(A1,1)<22/24,2/24+MIN(MOD(B1,1),6/24),1-MOD(A1,1)+MIN(MOD(B1,1),6/24))))*24)

Biff

"Biff" wrote in message
...
Hi!

Slightly shorter....

A1 = Date/Time in
B1 = Date/Time out

=IF(B1="","",IF(MOD(A1,1)<MOD(B1,1),MIN(MIN(MOD(B1 ,1),6/24)-MOD(A1,1),6/24),IF(MOD(A1,1)<22/24,2/24+MIN(MOD(B1,1),6/24),1-MOD(A1,1)+MIN(MOD(B1,1),6/24)))*24)

Note: Discovered rounding discrepancies during testing but they do not
effect the correctness of the results. For example:

A1 = 8/7/2005 10:00 PM

=MOD(A1,1) = 0.91666666666424100000

The time value: 10:00 PM is equivalent to 22/24 as used in the formula.
However:

22/24 = 0.91666666666666700000

Biff

"HappyTrucker"
wrote in message
...

OK, I think I've sorted it. Well it seems to work anyway. I don't know
whether I stumped you all, or it just wasn't clear enough. Or maybe the
problem wasn't interesting enough. Anyway, if anyone's interested,
here's what I came up with eventually. And my God is it a loooong one:

=IF(B15="","",IF(AND((B14<(LEFT(B14,5)+"22:00")),( B15<=(LEFT(B15,5)+"06:00"))),((B15-(LEFT(B14,5)+"22:00"))*24),IF(AND((B14=(LEFT(B14, 5)+"22:00")),
(B15<=(LEFT(B15,5)+"06:00"))),(B15-B14)*24,IF(AND((B14(LEFT(B14,5)+"22:00")),(B15=( LEFT(B15,5)+"06:00"))),(((LEFT(B15,5)+"06:00")-B14)*24),8))))




--
HappyTrucker
------------------------------------------------------------------------
HappyTrucker's Profile:
http://www.excelforum.com/member.php...o&userid=25997
View this thread:
http://www.excelforum.com/showthread...hreadid=393601





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 hours and minutes Patrick Excel Worksheet Functions 16 June 18th 08 09:24 PM
creating a formula for a timecard obiding by CA OT laws ness Excel Worksheet Functions 4 May 26th 05 07:51 PM
Need a function that separates over-lapping work shift hours. Katybug1964 Excel Worksheet Functions 0 May 24th 05 03:32 PM
calculate difference in time to hours Chris Excel Worksheet Functions 5 January 18th 05 06:07 PM
need help w/formula for calculating overtime hours jv749297 Excel Worksheet Functions 1 January 17th 05 07:54 PM


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