LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #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.


 
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:34 AM.

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"