ASP SQL Server Date Range and DateTime field

esquel

New Member
I am using Classic ASP and have the following VB script code\[code\]From8to14 = date-14To8to14 = date-8\[/code\]This sets the two variables. For today, this would mean that\[code\]From8to14 = "13/07/2012"To8to14 = "19/07/2012"\[/code\]I then have a select query to SQL server, and I want to find any records where the DateMatched column is between (and including) these two datesI have two conditions in the SQL when I declare it;\[code\]"AND INTRAY.DateMatched >= '"& Year(From8to14) &"-"& Month(From8to14) &"-"& Day(From8to14) &"' " & _"AND INTRAY.DateMatched <= '"& Year(To8to14) &"-"& Month(To8to14) &"-"& Day(To8to14) &"' " & _\[/code\]Now, this is not working properly because DateMatched column also includes a time in addition to the date, and I think the server is interepreting these dates as being at midnight at the start of that day ?So, if a record has a DateMatched of "19/07/2012 17:41:22" then it is not being included.How can I get around this?
 
Back
Top