与SQL相比,ASP函数返回意外结果

时间:2018-04-15 11:29:10

标签: sql-server asp-classic

 Function FreeDate(tdate, tindex)
     Set RSD = Server.CreateObject("ADODB.recordset")
     RSD.Open "SELECT COUNT(*) AS Total FROM tTable WHERE fId = " & tindex & " and Convert(datetime, '"& tdate & "') BETWEEN StartDate AND EndDate", Conn
     FreeDate = RSD("Total")
     RSD.Close
     Set RSD = Nothing
End Function

此功能返回1,参数' 2018-12-05'和31。

以下关于数据库的查询结果为Total(0):

SELECT Count(*) as Total
FROM tTable
WHERE Convert(datetime, '2018-12-05') BETWEEN StartDate AND EndDate AND fId = 31

我还没能确定为什么同一个查询不会产生相同的结果。

0 个答案:

没有答案