newbie needs help with date calculation (simple !)

philbennison

Registered User.
Local time
Today, 20:06
Joined
Nov 10, 2004
Messages
49
I am creating a database, and i have two fields 'date in' and 'date out'.
Is there a simple command to put in the table or form to work out how many working days have elapsed between the two dates. (Similar to 'networkdays' in excel).
I have no expierence with code, macros etc.
do i need to put in the command in the table,form, or query

Please help

Phil
 
Do a search on "Working days" - this crops up regularly.

Col
 
how do i do that

how do i do a search on 'working days' when that isnot a field ??

sorry if i'm being thick

Phil
 
Phil try this...

Function Work_Days(BegDate As Variant, EndDate As Variant) As Integer
' Note that this function does not account for holidays.
Dim WholeWeeks As Variant
Dim DateCnt As Variant
Dim EndDays As Integer
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
End Function
 

Users who are viewing this thread

Back
Top Bottom