The following code calcuates the difference in work days between two
dates:
Date 1 = [PosHireDate] or Position Hire Date
Date 2 = [RepDate] or Report Date
when I execute my query I get "#ERROR" for those records where the
[PosHireDate} is 'blank" or null
if i use:
You can trap for a null: If isnull([PosHireDate]) then
BusinessDays = 1000
or you can use NZ: NZ([PosHireDate],Date()) is my favorite in that
it runs but produces an obvious error.
to correct the error message and allow me to execute the code
my question is
Where would this line of code go in my original code?
thanks
dates:
Code:
Function BusinessDays(PosHireDate, RepDate) As Long
BusinessDays = (DateDiff("d", PosHireDate, RepDate) - _
(DateDiff("ww", PosHireDate, RepDate) * 2) + 1) + _
(Weekday(PosHireDate) = vbSunday) + _
(Weekday(RepDate) = vbSaturday)
End Function
Date 1 = [PosHireDate] or Position Hire Date
Date 2 = [RepDate] or Report Date
when I execute my query I get "#ERROR" for those records where the
[PosHireDate} is 'blank" or null
if i use:
You can trap for a null: If isnull([PosHireDate]) then
BusinessDays = 1000
or you can use NZ: NZ([PosHireDate],Date()) is my favorite in that
it runs but produces an obvious error.
to correct the error message and allow me to execute the code
my question is
Where would this line of code go in my original code?
thanks