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
我还没能确定为什么同一个查询不会产生相同的结果。