Hello I\'m using MS JET OLEDB 4.0 on VBA (MS ACCESS)
SQL = \"SELECT COUNT(Date) FROM [Orders] WHERE [Orders].[Date] BETWEEN \" & \"#\" & StartDate &
Use Format function.
SQL = "SELECT COUNT(Date)" & vbcr & _
"FROM [Orders]" & vbcr & _
"WHERE [Orders].[Date] BETWEEN #Format(" & StartDate & "], 'MM/dd/yyyy')# AND #Format(" & EndDate & ",'MM/dd/yyyy')#"
Always use ISO date formatting YYYY-MM-DD and you will have no problems. Without formatting.
I have noticed from the SQL compilation of the query when using Between, that it turns it to MM/DD/YYYY and it did not work till I used Format(startdate, "mm/dd/yyyy"). Please check the snapshop.