P
(PeteCresswell)
I'm doing this... and it works:
------------------------------------------------------------
Public Function DateWithinRange(ByVal theDate As Variant,
ByVal theBeginDate As Variant,
ByVal theEndDate As Variant) As Boolean
debugStackPush mModuleName & ": DateWithinRange"
On Error GoTo DateWithinRange_err
' PURPOSE: To determine whether-or-not a date is within a given range of dates
' ACCEPTS: - The date we want to check
' - First date in the range
' - Last date in range
' RETURNS: True if the date is within the range, Else False
Dim X As Long
Dim Y As Long
If ((IsDate(theDate)) And (IsDate(theBeginDate)) And (IsDate(theEndDate))) Then
X = DateDiff("d", theBeginDate, theDate)
If X > -1 Then
Y = DateDiff("d", theDate, theEndDate)
If Y > -1 Then
DateWithinRange = True
End If
End If
End If
DateWithinRange_xit:
DebugStackPop
On Error Resume Next
Exit Function
DateWithinRange_err:
BugAlert True, ""
Resume DateWithinRange_xit
End
----------------------------------------------------------
But it seems like wretched excess for such a "bread-and-butter" calculation.
(Albeit some of the excess is for debuggability - as in storing the diffs
in the temp fields X and Y)
So... what VBA syntax am I missing that would do it more concisely?
------------------------------------------------------------
Public Function DateWithinRange(ByVal theDate As Variant,
ByVal theBeginDate As Variant,
ByVal theEndDate As Variant) As Boolean
debugStackPush mModuleName & ": DateWithinRange"
On Error GoTo DateWithinRange_err
' PURPOSE: To determine whether-or-not a date is within a given range of dates
' ACCEPTS: - The date we want to check
' - First date in the range
' - Last date in range
' RETURNS: True if the date is within the range, Else False
Dim X As Long
Dim Y As Long
If ((IsDate(theDate)) And (IsDate(theBeginDate)) And (IsDate(theEndDate))) Then
X = DateDiff("d", theBeginDate, theDate)
If X > -1 Then
Y = DateDiff("d", theDate, theEndDate)
If Y > -1 Then
DateWithinRange = True
End If
End If
End If
DateWithinRange_xit:
DebugStackPop
On Error Resume Next
Exit Function
DateWithinRange_err:
BugAlert True, ""
Resume DateWithinRange_xit
End
----------------------------------------------------------
But it seems like wretched excess for such a "bread-and-butter" calculation.
(Albeit some of the excess is for debuggability - as in storing the diffs
in the temp fields X and Y)
So... what VBA syntax am I missing that would do it more concisely?