WorkDays Problem Works with US not European Date

jeff_i

Registered User.
Local time
Today, 12:49
Joined
Jan 24, 2003
Messages
50
I am using this piece of code which I found on the forum well for US dates it works correctly however with european dates it does not.

[/code]
Function Work_Days(BegDate As Variant, enddate As Variant) As Integer
Dim WholeWeeks As Variant
Dim DateCnt As Variant
Dim EndDays As Integer
Dim HolidayCnt As Integer



HolidayCnt = DCount("*", "tblHolidays", "HolidayDate >= " & BegDate & " AND HolidayDate <= " & enddate & "")

BegDate = DateValue(BegDate)

enddate = DateValue(enddate)
WholeWeeks = DateDiff("w", BegDate, enddate)
DateCnt = DateAdd("ww", WholeWeeks, BegDate)
EndDays = 0
Do While DateCnt < enddate
If Format(DateCnt, "ddd") <> "Sun" And _
Format(DateCnt, "ddd") <> "Sat" Then
EndDays = EndDays + 1
End If
DateCnt = DateAdd("d", 1, DateCnt)
Loop
Work_Days = WholeWeeks * 5 + EndDays - HolidayCnt



End Function

[/code]

As an example if calculate workdays between August 26, 2004 and September 7, 2004 with my region as US then I get 8 days, if I change the regional settings to Danish I get 10 days which is incorrect. I can't figure out what I am doing wrong.

Thanks for any help!
 
Thanks Rich,

I am sorry to say I don't understand what you mean. I have attempted to use the format function on the dates but still have no luck.

Jeff
 

Users who are viewing this thread

Back
Top Bottom