Querying dates from dbf in macro

Discussion in 'Visual Basic ( VB )' started by ill_comms, Feb 21, 2011.

  1. ill_comms

    ill_comms New Member

    Joined:
    Feb 16, 2011
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    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
     
  2. ill_comms

    ill_comms New Member

    Joined:
    Feb 16, 2011
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    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.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice