Access Date comparison Problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • amolbehl
    New Member
    • May 2007
    • 63

    Access Date comparison Problem

    Hi I am trying to use the following query to get all dates in a particular range please let me know wht I am doing wrong

    Code:
    SELECT Unique_Sets_Bulk.CustomerNo, Unique_Sets_Bulk.OrderDate, Unique_Sets_Bulk.RouteNo
    FROM Unique_Sets_Bulk
    WHERE (((CDate([OrderDate]))>="#1/1/2005#" And (CDate([OrderDate]))<="#12/1/2009#"));
  • Delerna
    Recognized Expert Top Contributor
    • Jan 2008
    • 1134

    #2
    Nothing obvious stands out
    Try putting the CDate(orderDate ) into your select fieldlist and see
    that it is in the correct format for the comparison to work

    Comment

    • missinglinq
      Recognized Expert Specialist
      • Nov 2006
      • 3533

      #3
      WHERE (((CDate([OrderDate]))>="#1/1/2005#" And (CDate([OrderDate]))<="#12/1/2009#"));

      I think you need to lose the quotation marks around the dates, they're turning your dates into strings. Date literals are delimited by the pound sign alone.

      Linq ;0)>

      Comment

      • ADezii
        Recognized Expert Expert
        • Apr 2006
        • 8834

        #4
        Originally posted by amolbehl
        Hi I am trying to use the following query to get all dates in a particular range please let me know wht I am doing wrong

        Code:
        SELECT Unique_Sets_Bulk.CustomerNo, Unique_Sets_Bulk.OrderDate, Unique_Sets_Bulk.RouteNo
        FROM Unique_Sets_Bulk
        WHERE (((CDate([OrderDate]))>="#1/1/2005#" And (CDate([OrderDate]))<="#12/1/2009#"));
        [CODE=sql]
        SELECT Unique_Sets_Bul k.CustomerNo, Unique_Sets_Bul k.OrderDate, Unique_Sets_Bul k.RouteNo, CDate([OrderDate]) AS Converted_Date
        FROM Unique_Sets_Bul k
        WHERE CDate([OrderDate])>=#1/1/2005# And CDate([OrderDate])<=#12/1/2009#;[/CODE]

        Comment

        • amolbehl
          New Member
          • May 2007
          • 63

          #5
          Yup It works ... thanx a lot

          Comment

          Working...