dates need to be strings they so they needs quotes. here is what a typical SQL statement that gets data between two dates looks like:
SELECT filedName FROM tbleName WHERE (dateTypeFieldName >= '7/21/2012') AND (dateTypeFieldName <= '8/22/2012')
Yours should be giving you an error, does it run like that....
Notice my is mm/dd/yyyy - We use dd/mm/yyyy here is aussie but I always query SQL Server in American format. using this function
Code:
FUNCTION amDate(varDate)
IF isNull(varDate) OR Trim(varDate) = "" OR varDate = "Null" THEN
amDate = "Null"
ELSE
amDate = "'" & Day(DateValue(varDate)) & "/" & Month(DateValue(varDate)) & "/" & Year(DateValue(varDate)) & " " & TimeValue(varDate) & "'"
END IF
END FUNCTION
so when you write your SQL do this:
Code:
sql = "SELECT filedName FROM tbleName WHERE (dateTypeFieldName >= " & amDate(request.form("dateFrom")) & ") AND (dateTypeFieldName <= " & amDate(request.form("dateTo")) & ")
NOTE - the amDate function placed single quotes arounf the value this is why I do this:
" & amDate(request.form("dateFrom")) & "
instead of this:
'" & amDate(request.form("dateFrom")) & "'