Michael,
I have attached my code below, I have even converted to double just before i return the result but still no joy...
I am I missing something vital here ?
Any input you have wuold be most helpful!
Public Function NonWorkingDays(ByVal DateIn As Date, ByVal DateOut As Date)
On Error GoTo CalcError:
Dim TotalHours As Long
Dim HoursToDrop As Long
Dim StartDate As Date
Dim EndDate As Date
'set up start/end dates/totalhours and reset hourstodrop to 0
StartDate = Format(DateIn, "general date"

EndDate = Format(DateOut, "general date"

TotalHours = DateDiff("n", StartDate, EndDate)
HoursToDrop = 0
Dim WeekStart As Byte
Dim WeekEnd As Byte
WeekStart = WeekDay(StartDate)
WeekEnd = WeekDay(EndDate)
Dim Monday As Date
Dim NewString As String
'if received and completed on sat or sun then calc hours only or set first working day to monday morning
Select Case WeekStart
Case 1
If WeekEnd = 1 And TotalHours < 1440 Then
NonWorkingDays = Format(TotalHours / 60, "0.0"

Exit Function
Else
NewString = StartDate + 1
NewString = Left(NewString, 8) & " 08:00"
Monday = NewString
HoursToDrop = DateDiff("n", StartDate, Monday)
End If
Case 7
If WeekEnd = 7 Or WeekEnd = 1 And TotalHours < 2880 Then
NonWorkingDays = Format(TotalHours / 60, "0.0"

Exit Function
Else
NewString = StartDate + 2
NewString = Left(NewString, 8) & " 08:00"
Monday = NewString
HoursToDrop = DateDiff("n", StartDate, Monday)
End If
End Select
'add up all sat/sun between startdate and end date
Dim DateCounter As Date
Select Case NewString
Case ""
DateCounter = StartDate
Do
If WeekDay(DateCounter) = 7 Or WeekDay(DateCounter) = 1 Then
HoursToDrop = HoursToDrop + 1440
End If
DateCounter = DateCounter + 1
Loop While DateCounter < EndDate
Case Else
DateCounter = NewString
Do
If WeekDay(DateCounter) = 7 Or WeekDay(DateCounter) = 1 Then
HoursToDrop = HoursToDrop + 1440
End If
DateCounter = DateCounter + 1
Loop While DateCounter < EndDate
End Select
'Too DAMN SLOOOOOOOOOOW with this piece of code!! was a dcount on holiday table
'Dim HoliDays As Integer
'
' HoliDays = DCount("holidate", "holidaytable", "(holidate Between #" & Format(StartDate, "short date"

& "# And #" & Format(EndDate, "short date"

& "#)"

' If Not HoliDays = 0 Then
' HoliDays = HoliDays * 1440
' HoursToDrop = HoursToDrop + HoliDays
' End If
'instead use an array created on app start
Dim J As Date
Dim I As Byte
Dim Holidays As Long
StartDate = Format(StartDate, "short date"

EndDate = Format(EndDate, "short date"
For J = StartDate To EndDate
For I = 0 To UBound(HoliArray) - 1
If Not WeekDay(J) = 1 Or WeekDay(J) = 7 Then
If HoliArray(I) = J Then
Holidays = Holidays + 1
End If
End If
Next I
Next J
If Holidays <> 0 Then
Holidays = Holidays * 1440
HoursToDrop = HoursToDrop + Holidays
End If
'true working hours is total hours minus the hours to be dropped - and there you go !
NonWorkingDays = TotalHours - HoursToDrop
If NonWorkingDays < 0 Then NonWorkingDays = NonWorkingDays + Holidays
NonWorkingDays = CDbl(Format(NonWorkingDays / 60, "0.0"

)
Exit Function
CalcError:
If Err.number = 94 Or Err.number = 13 Then
NonWorkingDays = Null
Else
DisplayMessage "Please report 'TR calc error - " & Err.number & " " & Err.Description & " '"
End If
End Function
Thx alot!!
