dates problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • charvi
    New Member
    • May 2007
    • 121

    dates problem

    Hi all
    i have access databae in which a table consists of all staff details with dat now if want to retrieve records between 5/01/2008 to 10/01/2008.i dot know the syntax of using between query can u pls help
  • QVeen72
    Recognized Expert Top Contributor
    • Oct 2006
    • 1445

    #2
    Originally posted by charvi
    Hi all
    i have access databae in which a table consists of all staff details with dat now if want to retrieve records between 5/01/2008 to 10/01/2008.i dot know the syntax of using between query can u pls help
    Hi,

    Check this :

    SELECT * From MyTable Where MYDate Between #05-01-2008#
    And #10-01-2008#

    Regards
    Veena

    Comment

    • charvi
      New Member
      • May 2007
      • 121

      #3
      rs.Open "select * from timesheet where date between #" & mskfrom & "#" And "# & mskTo & #", con, adOpenDynamic, adLockOptimisti c

      I have written this ode but it giv me runtime error.
      pls help

      Comment

      • charvi
        New Member
        • May 2007
        • 121

        #4
        Originally posted by charvi
        rs.Open "select * from timesheet where date between #" & mskfrom & "#" And "# & mskTo & #", con, adOpenDynamic, adLockOptimisti c

        I have written this ode but it giv me runtime error.
        pls help
        when writethis code it gives all the records..e if i want to search between 2/01 and 5/01 igives me al recordsof 6/1 ,7/01 so on

        Comment

        • charvi
          New Member
          • May 2007
          • 121

          #5
          Originally posted by charvi
          when writethis code it gives all the records..e if i want to search between 2/01 and 5/01 igives me al recordsof 6/1 ,7/01 so on
          i getthis dateproble when i enter in the form of mm/dd/yyyy in mskedbox1 though i have formatted maskedbox as dd/mm/yyyy why is it pls help

          Comment

          • Killer42
            Recognized Expert Expert
            • Oct 2006
            • 8429

            #6
            Originally posted by charvi
            i getthis dateproble when i enter in the form of mm/dd/yyyy in mskedbox1 though i have formatted maskedbox as dd/mm/yyyy why is it pls help
            You need to show us the exact string which is being passed to Access. The fact that the masked edit control shows something in a particular format on the form doesn't tell us anything about what you're getting out of it.

            Pretty sure Access demands U.S. date format (MM/DD/YYYY) so the syntax should be something like...

            SELECT * From MyTable Where MyDate Between #01/05/2008# And #01/10/2008#

            Alternatively, you might avoid the date format issue by using an unambifuous format. That is, one in which the month and day cannot be confused. For example...

            SELECT * From MyTable Where MyDate Between #05-Jan-2008# And #10-Jan-2008#

            Comment

            Working...