Quote:
command.Parameters.AddWithValue("@Day", day.Trim() & "-" & DateTime.Now.Day.ToString())
You're passing a string to the query which cannot be interpreted as a valid
datetime
by SQL. For example, if
day
is
"2"
, you are passing in
"2-21"
, which is obviously not a valid date.
Pass in date parameters as dates:
command.Parameters.AddWithValue("@Day", DateTime.Today)
It's not clear from your question what date range you are actually trying to view. If it's the current month starting on the specified day, for example:
Dim dayNumber As Integer
If Not Integer.TryParse(day, dayNumber) Then
Return
End If
Dim today As DateTime = DateTime.Today
Dim dayValue As New DateTime(today.Year, today.Month, dayNumber)
command.Parameters.AddWithValue("@Day", dayValue)