You shouldn't use the Format
function to get date components. Format
is used to return a formatted string of the specified date. VB is doing you a favor by casting the string to an integer for your comparison. Use VB's Day()
, Month()
, or Year()
functions to extract date components instead.
Dim intDay As Integer
intDay = Day(Date)
Select Case intDay
Case 13 To 15, 26 To 30
' Match
Case Else
' No Match
End Select