I am using the function below to extract data from another workbook. It works for non-Date columns, but does not work for a column which holds dates
Worksheet looks like
Works if is not a date column:
Debug.Print GetSheetSQL(workbookPath, "Select columna from [sheet$]")(1)("columna")
--> Returns "palim"
Does not work if a is a date column
Debug.Print GetSheetSQL(workbookPath, "Select columnb from [sheet$]")(1)("columnb")
--> Returns Nothing
Function GetSheetSQL(path As String, sqlStr As String) As Collection
'''''''''''''''''''''''''''''''''''''''
'Open ADOB Connection and query via sql
' Connection string is standard and
' taken from:
' https://www.connectionstrings.com/microsoft-jet-ole-db-4-0/standard-excel/
Dim objConnection As Object
Dim objRecordSet As Object
Set objConnection = CreateObject("ADODB.Connection")
Set objRecordSet = CreateObject("ADODB.Recordset")
Const adOpenStatic = 3
Const adLockOptimistic = 3
Const adCmdText = &H1
objConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & path & ";Extended Properties=""Excel 8.0;HDR=Yes"""
objRecordSet.Open sqlStr, objConnection, adOpenStatic, adLockOptimistic, adCmdText
'''''''''''''''''''''''''''''''''''''''
'Iterate through queried table
' table is a collection with a row per row in the table
' row is a dictionary with table headings as key, returning the corresponding value
Dim table As Collection
Set table = New Collection
Dim row As Object
Dim fld
'iterate through recordset rows
Do Until objRecordSet.EOF
With objRecordSet
Set row = CreateObject("Scripting.Dictionary")
For Each fld In .Fields
row.Add fld.Name, fld.Value
Next fld
table.Add row
.MoveNext
End With
Loop
Set GetSheetSQL = table
'Close Connection; reset Error Handling to default
objConnection.Close
On Error GoTo 0
Exit Function
ErrorCloseConn:
objConnection.Close
On Error GoTo 0
Resume
End Function



Returns Nothing?"Select ... [sheet$]"