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
This function returns 1 with the parameters '2018-12-05' and 31.
The following query on the database results in Total (0) :
SELECT Count(*) as Total
FROM tTable
WHERE Convert(datetime, '2018-12-05') BETWEEN StartDate AND EndDate AND fId = 31
I haven't been able to determine why the same query would not yield the same result.