Searching for date/time in access table

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • skyshare
    New Member
    • Sep 2014
    • 1

    Searching for date/time in access table

    Hi

    I have an access table containing two fields named arr_date and dep_date, both date/time format i.e 'dd/mm/yyyy hh:mm:ss'

    Using VB6 I am trying to select the records from the a table named data_2014 with dates/times where a date/time variable is between the arr_date and dep_date. However it is not returning any results or is showing 'type mismatch'. Any offers on how to do this please?

    dt is declared as Date and is in format 'dd/mm/yyyy hh:mm:ss'

    The code tried is:

    "select * from data_2014 where #" & dt & "# between [arr_time] and [dep_time] "



    thanks
  • twinnyfo
    Recognized Expert Moderator Specialist
    • Nov 2011
    • 3662

    #2
    skyshare,

    First, we need the name of the field you are looking for in the table data_2014. Assuming the name of the field is "dt" (from your code), then try this:

    Code:
    "SELECT * FROM data_2014 " & _
        "WHERE dt Between #" & [arr_time] & "# " & _
        "AND #" & [dep_time] & "#;"
    Hope this hepps!

    Comment

    Working...