#1   Report Post  
Oi you
 
Posts: n/a
Default Timesheet problem

I use an Excel 2000 spreadsheet to log sub-contract work hours - and
as the hours are then used to calculate charges I use separate hours
and minutes columns (start hh, start mm; finish hh, finish mm). That
seemed the easiest way to me.

Everything is working just how I want it, but....I now need to
introduce a night charge:

A shift can start anytime day/night and finish anytime day/night. If,
the shift includes ANY time worked between 1 am and 4 am I then need to
(a) invoke an extra charge and (b) do some other checks in a different
spreadsheet.

How do I get Excel to test for this? Thanks for your help.

  #2   Report Post  
Bob Phillips
 
Posts: n/a
Default Timesheet problem

Bit difficult without knowing what the data looks like, but making some
assumptions

If A1 holds the start time
B1 holds the finish time
The time worked between 02:00 and 04:00 can be calculated with

=IF(A1<TIME(4,0,0),MIN(B1,TIME(4,0,0)),0)-IF(A1<=TIME(4,0,0),MAX(A1,TIME(1,0
,0)),0)

This will not work if the start and end times are in different days.

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"Oi you" wrote in message
oups.com...
I use an Excel 2000 spreadsheet to log sub-contract work hours - and
as the hours are then used to calculate charges I use separate hours
and minutes columns (start hh, start mm; finish hh, finish mm). That
seemed the easiest way to me.

Everything is working just how I want it, but....I now need to
introduce a night charge:

A shift can start anytime day/night and finish anytime day/night. If,
the shift includes ANY time worked between 1 am and 4 am I then need to
(a) invoke an extra charge and (b) do some other checks in a different
spreadsheet.

How do I get Excel to test for this? Thanks for your help.



  #3   Report Post  
Stefi
 
Posts: n/a
Default Timesheet problem

This function returns day and night work hours even if end time is in the
next date (the maximum difference between end time and start time is 24
hours).

Public Function Shifttime2(starttime As Date, endtime As Date, daytime As
Integer, _
startday As Date, startnight As Date)
Dim length As Variant
Dim timeday As Date, timenight As Date
If starttime = endtime Then endtime = 1 + endtime
If startday = startnight Then startnight = 1 + startnight
length = endtime - starttime
timeday = WorksheetFunction.Max(0, length - WorksheetFunction.Max(0,
endtime - startnight)) _
+ WorksheetFunction.Max(0, endtime - (1 + startday)) _
- WorksheetFunction.Max(0, endtime - (1 + startnight))

timenight = WorksheetFunction.Max(0, length - WorksheetFunction.Max(0,
startnight - starttime)) _
- WorksheetFunction.Max(0, endtime - (1 + startday)) _
+ WorksheetFunction.Max(0, endtime - (1 + startnight))
Select Case daytime
Case 1
Shifttime2 = timeday
Case 2
Shifttime2 = timenight
Case Else
Shifttime2 = "Invalid daytime!"
End Select
End Function

Regards,
Stefi


"Oi you" wrote:

I use an Excel 2000 spreadsheet to log sub-contract work hours - and
as the hours are then used to calculate charges I use separate hours
and minutes columns (start hh, start mm; finish hh, finish mm). That
seemed the easiest way to me.

Everything is working just how I want it, but....I now need to
introduce a night charge:

A shift can start anytime day/night and finish anytime day/night. If,
the shift includes ANY time worked between 1 am and 4 am I then need to
(a) invoke an extra charge and (b) do some other checks in a different
spreadsheet.

How do I get Excel to test for this? Thanks for your help.


  #4   Report Post  
Oi you
 
Posts: n/a
Default Timesheet problem

Thanks everyone for your help. The answer I am now using (courtesy of
Mrexcel.com) is very elegant and works in all circumstances I have
tried. Thought you might be interested in it too:

=IF(OR(AND(startHH=1,startHH<4), AND(finishHH=1,finishHH<=4),
AND(finishHH=4,finishHH-totalhours<4)),"Yes","")

This works for finish hours in 24 hour format but it was quite simple
to adjust to suit my spreadsheet. It returns "Yes" if any hours were
worked between 1am and 4 am and I have been able to take it from
there.

Buggered if I know how it works but it does!

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
Freeze Pane problem in shared workbooks JM Excel Discussion (Misc queries) 1 February 1st 05 12:04 AM
overtime on timesheet kimmyrt Excel Worksheet Functions 4 January 26th 05 07:33 PM
timesheet with running total of overtime kimmyrt Excel Worksheet Functions 2 January 26th 05 06:15 PM
Row Autofit problem Excel 2003 Matthias Klaey Excel Discussion (Misc queries) 0 January 19th 05 05:33 PM
Timesheet Problem GregR Excel Discussion (Misc queries) 4 December 6th 04 07:04 PM


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