Morning all,
I am hoping this is a quick one. I have a query in Excel that requests records between two date points. It returns without errors but also returns unexpected values, seemingly because the date has been swapped around. I am working with the UK date format (dd/mm/yyy).
I have tried passing the date as a date type and a string type, as a datevalue and just the text. I have also tried passing it as yyyymmdd.
In the below example sFromDate is 06/04/2016 (6th April) and sToDate is 12/04/16 (12th April). Dates between June and December are being returned.
sSelectedArea = "ThisTMRacf"
sFromDate = DateValue(Sht_SpecificView.Range("D5"))
sToDate = DateValue(Sht_SpecificView.Range("F5"))
Set rex = db.OpenRecordset("SELECT eGain.RecordDate FROM [eGain], [Staff] 
WHERE eGain.Racf = Staff.Racf AND (Staff.TeamManager = '" & sSelectedArea & "' 
OR Staff.CSM = '" & sSelectedArea & "') 
AND eGain.RecordDate BETWEEN #" & sFromDate & "# AND #" & sToDate & "# ;")
Is there another way to pass the date so that it doesn't convert?