hi,
use the below function ..paste it into ur module
Function find_weekdays(BegDate As Variant, EndDate As Variant) As Integer
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
find_weekdays = Work_Days
End Function
and call this function from ur query with 2 parameters...
for eg:
select find_weekdays(#12/1/2005#,#12/12/2005#)-1 will return 7...this the
number of working days..i excluded saturday and sunday....
psl let me know if this helps u
thanks
with regds
Sunil.T
Paul Dennis - 02 Dec 2005 11:54 GMT
Created the module, but having problems with the select. Trying to put it in
using the Expression Builder but getting syntax errors. Tried in a seperate
query and used the SQL and managed to save the query but now get error
'Undefined function'.
Hence I have 2 problems - why is it an undefined function and then how to
have it as another field in a larger query?
sorry to be a pain.
> hi,
>
[quoted text clipped - 37 lines]
>
> Sunil.T
> I have 2 dates/times which I need to take one from the other, however if
> between these 2 dates there is a weekend I need to remove 48 hrs.
[quoted text clipped - 3 lines]
>
> Any ideas - please?
Paul Dennis,
Calculate Number of Working Days:
http://www.mvps.org/access/datetime/date0006.htm
Sincerely,
Chris O.