Querying dates from dbf in macro

ill_comms's Avatar, Join Date: Feb 2011
Newbie Member
Hi All,

In my code I have this select statement that I'm trying to put together but the query is recognizing the day as the month in the from_date and getting it right in the to_date, I guess for an obvious reason there's no 13th month. I've tried using '-' instead of '/'.

I basically want it to recognize it as dd/mm/yyy

Any advice would be greatly appreciated!

from_date = "11/01/2011"
to_date = "13/01/2011"

Set cn = CreateObject("ADODB.Connection")
Set rs = CreateObject("ADODB.Recordset")
cn.Open "driver={Microsoft dBase Driver (*.dbf)}; driverid=277;dbq=" + rootdir + "\MAINT\"
c1SQL = "Select OccurDate from LnMt.dbf Where OccurDate >= #" + temp_date + "# And OccurDate <= #" + to_date + "#"
rs.Open c1SQL, cn, , , adCmdText
ill_comms's Avatar, Join Date: Feb 2011
Newbie Member
Also I'm not sure if it is the variable or the field that it's reversing, they are both type in correctly. There are dates entered in the OccurDate field 12/01/2011.