I am trying to evaluate aging tickets... breaking them up in age ranges. I've created a function that seems like it should do this, but when I run through the code the "TO" keyword in my Case statement doesn't seem to be working correctly.
here's my code"
What happens here is... intAge comes out to 460... which should make strRange = "90+"
but instead Case 90 to 999 doesn't seem to trigger and thusly it's making strRange = "NA"
Why wouldn't an intAge value of 460 make that case statement trigger when it hits 90 to 999?
here's my code"
Function Get_Time_Span(ByVal dtBeg As Date, ByVal dtEnd As Date, ByVal dtFinalDay As Date, ByVal intFillMonth As Integer) As String
Dim strSQL As String
Dim strRange, strLastDay As String
Dim dtFill As Date
Dim intAge, intMonthRange, intDaysAfterClose, intFillYear As Integer
Dim intFillPosition, intEndPosition, intBegPositon As Integer
'---------------------------------------------------------------------
' If Month(dtFinalDay) - intFillMonth is positive then Fill Month is
' in the same year as the Final Report Month.
' Negative means FIll Month is for the prior year
'---------------------------------------------------------------------
intFillPosition = Month(dtFinalDay) - intFillMonth
If intFillPosition > 0 Then
intFillYear = Year(dtFinalDay)
Else
intFillYear = Year(dtFinalDay) - 1
End If
'Put Fill date together
Select Case intFillMonth
Case 1, 3, 5, 7, 8, 10, 12
strLastDay = "31"
Case 4, 6, 9, 11
strLastDay = "30"
Case 2
If (intFillYear Mod 4) = 0 Then
strLastDay = "29"
Else
strLastDay = "28"
End If
End Select
dtFill = CDate(CStr(intFillMonth) & "/" & strLastDay & "/" & CStr(intFillYear))
'-----------------------------------------------------------------------
' Check if fill date falls within Create and resolve dates
' note that open tickets have a resolve date of dtFinalDay
'-----------------------------------------------------------------------
If dtBeg <= dtFill <= dtEnd Then
intAge = DateDiff("d", dtBeg, dtFill)
Select Case intAge
Case 1 To 9
strRange = "NA"
Case 10 To 29
strRange = "10 - 29"
Case 30 To 59
strRange = "30 - 59"
Case 60 To 89
strRange = "60 - 89"
Case 90 To 999
strRange = "90+"
Case Else
strRange = "NA"
End Select
Else
strRange = "NA"
End If
Get_Time_Span = strRange
End Function
What happens here is... intAge comes out to 460... which should make strRange = "90+"
but instead Case 90 to 999 doesn't seem to trigger and thusly it's making strRange = "NA"
Why wouldn't an intAge value of 460 make that case statement trigger when it hits 90 to 999?