KB Issue
When using a datediff within your SQL Queries, you have to make sure that the parameters that you are using are correctly written and used.
Issue Details
When you have to use the DateDiff within your SQL Queries (Select Statements), make sure that you use the parameters correctly; if not, you will receive the following error within the SQL Server Management Studio.
Msg 1023, Level 15, State 1, Line 1
Invalid parameter 1 specified for datediff.
Within ASP, you will receive the following Error:
Microsoft OLE DB Provider for SQL Server error '80040e14'
Invalid parameter 1 specified for datediff.
/StatComs.asp, line 14
Recreate Issue
Code Example
sql.commandtext="select datediff('s', MyDate, getdate()) as date from table"

The above will give you the error due to the single quotes around the 's'
Copy
Search Site
Search Google
Resolve Issue
Code Example
sql.commandtext="select datediff(s, MyDate, getdate()) as date from table"

As you can see in the above statement, we have removed the single Quotes from the s
Copy
Search Site
Search Google
from the statement.