Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Visual Basic ( VB ) (http://www.go4expert.com/forums/visual-basic/)
-   -   Querying dates from dbf in macro (http://www.go4expert.com/forums/querying-dates-dbf-macro-t25042/)

ill_comms 21Feb2011 20:29

Querying dates from dbf in macro
 
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!
Hayden


Code:

'dd/mm/yyyy
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 21Feb2011 20:47

Re: Querying dates from dbf in macro
 
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.


All times are GMT +5.5. The time now is 03:37.