ADODB.Recordset 中小时 >24 时 AVG() 时间的错误结果

Wrong result with AVG() time when hour >24 in ADODB.Recordset

有人可以帮助我理解为什么,当我 运行 这段代码每次在我们的数据范围内时,我检索到错误的结果(示例 table 是 25K 记录的摘录)有记录Kpi1-2 > 24H.

Set objConnection = CreateObject("ADODB.Connection")
Set objRecordset = CreateObject("ADODB.Recordset")

DBPath = ThisWorkbook.FullName
objConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    "Data Source=" & ThisWorkbook.FullName & ";" & _
        "Extended Properties=""Excel 8.0;HDR=Yes;"";"    

Strsql:Select [DataAttesa] as Data, avg([Kpi1-2]) as nr FROM [db_In$] Where TypeTrasp  = 'STD' and [1-2_ESITO] in ('90%','100%','Out of Time','On Going') group by [DataAttesa] Order by [DataAttesa]asc

    objRecordset.Open strsql, objConnection, adOpenStatic, adLockReadOnly, adCmdUnspecified
       Do Until objRecordset.EOF
         debug.print objRecordset.Fields.item("nr")
         objRecordset.MoveNext
      Loop
    objRecordset.Close

更新: 我测试这段代码:

debug.print objRecordset.Fields.item("nr")
in the immediate windows I see: 21/01/1900  11:41:00
if I test tu put the result into a cell:

Cells(20, 7) = objRecordset.Fields.item("nr") 
the cells.value will be 22/01/1900  11:41:25
Cells(21, 7) = Format(objRecordset.Fields.item("nr"), "dd/mm/yyyy hh:mm;@")
the cells.value will be 21/01/1900  11:41:25

只有第二个是正确的。 为什么?!?!什么追加?!?

此post中讨论了此问题的解决方案:

我插入 link 如果它可以帮助任何其他用户

法布里齐奥