Count Work Days

G

Guest

I am trying to Count the number of work days between two dates in a query i
tryed using dhCountWorkdaysA([Date_Open],Date()) that i got form this board
but i get a err Undefined Function 'dhCountWorkdays' in expression.
C an anyone help me with this?


SELECT qryAll.[Date_Open], DateDiff("d",[Date_ Open],Date()) AS
[Days_Open], dhCountWorkdaysA([Date_ Open],Date()) AS [Work_ Days]
FROM qryAll
GROUP BY qryAll.[Date_Open],
DateDiff("d",[Date_Open],Date()),dhCountWorkdaysA([Date_Open],Date());
Octet
 
G

Guest

To use a function in a query, it needs to be a Public Function in a standard
module.
 
G

Guest

I get a Syntax error at this point in the code I copied this code fron this
board does anyon know what rhe problem is?

between #" _
' & dtmStart & "# And #" & dtmEnd & "#")



Function CalcWorkDays(dtmStart As Date, dtmEnd As Date) As Integer

On Error GoTo CalcWorkDays_Error

'Calculates the number of days between the dates
'Add one so all days are included
CalcWorkDays = DateDiff("d", dtmStart, dtmEnd) - _
(DateDiff("ww", dtmStart, dtmEnd, 7) + _
DateDiff("ww", dtmStart, dtmEnd, 1)) + 1
'Subtract the Holidays
' CalcWorkDays = CalcWorkDays - DCount("*", "holidays", "[holdate]
between #" _
' & dtmStart & "# And #" & dtmEnd & "#")

CalcWorkDays_Exit:

On Error Resume Next
Exit Function

CalcWorkDays_Error:

MsgBox "Error " & Err.Number & " (" & Err.Description & _
") in procedure CalcWorkDays of Module modDateFunctions"
GoTo CalcWorkDays_Exit

End Function


Klatuu said:
To use a function in a query, it needs to be a Public Function in a standard
module.
--
Dave Hargis, Microsoft Access MVP


Octet32 said:
I am trying to Count the number of work days between two dates in a query i
tryed using dhCountWorkdaysA([Date_Open],Date()) that i got form this board
but i get a err Undefined Function 'dhCountWorkdays' in expression.
C an anyone help me with this?


SELECT qryAll.[Date_Open], DateDiff("d",[Date_ Open],Date()) AS
[Days_Open], dhCountWorkdaysA([Date_ Open],Date()) AS [Work_ Days]
FROM qryAll
GROUP BY qryAll.[Date_Open],
DateDiff("d",[Date_Open],Date()),dhCountWorkdaysA([Date_Open],Date());
Octet
 
G

Guest

I got it but shouldent the commet be removed?

' CalcWorkDays = CalcWorkDays - DCount("*", "holidays", "[holdate]
between #"_
' & dtmStart & "# And #" & dtmEnd & "#")
 
G

Guest

Yes, the comment mark should be removed, sorry, I had it in a place where I
did not have the table.
As to the syntax problem in your other post.
between #" _
' & dtmStart & "# And #" & dtmEnd & "#")

Is using the line continuation mark, the underscore. On one line it should
look like this:
between "#" & dtmStart & "# And #" & dtmEnd & "#")

--
Dave Hargis, Microsoft Access MVP


Octet32 said:
I got it but shouldent the commet be removed?

' CalcWorkDays = CalcWorkDays - DCount("*", "holidays", "[holdate]
between #"_
' & dtmStart & "# And #" & dtmEnd & "#")

Octet32 said:
I am trying to Count the number of work days between two dates in a query i
tryed using dhCountWorkdaysA([Date_Open],Date()) that i got form this board
but i get a err Undefined Function 'dhCountWorkdays' in expression.
C an anyone help me with this?


SELECT qryAll.[Date_Open], DateDiff("d",[Date_ Open],Date()) AS
[Days_Open], dhCountWorkdaysA([Date_ Open],Date()) AS [Work_ Days]
FROM qryAll
GROUP BY qryAll.[Date_Open],
DateDiff("d",[Date_Open],Date()),dhCountWorkdaysA([Date_Open],Date());
Octet
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top