Access date parameter problem

Ask a Question related to Coldfusion Database Access, Design and Development.

  1. #1

    Default Access date parameter problem

    I have been struggling with this for days. I am using a form to retrieve a list
    of dates and of store numbers. The user selects a date and store number from
    each list and the form send the selections to another page. I have the date
    formatted as #DateFormat(Visit_Date, "mm/dd/yyyy")#. This page is working
    properly. The second page is where I am having problems. This page has two
    cfsets, one for location number and another for the date. When I use only the
    location number only, the database returns the correct results. When I use the
    date parameter (both alone and with the location number parameter) the query
    retrieves 0 rows. Yet if I type the exact same date in Access and run the query
    it works. Below is the query using the ColdFusion debugging tool to see the
    exact query being submitted (I have bolded the trouble area).

    From the debugging report;
    SELECT Locations.Location_ID, Locations.Location_Code, Visits.Visit_Date,
    Visits.Visit_Time, PointRanges1.Group_Label, QuestionSet1.Question_MainText,
    QuestionSet1.A_Answer_Points, Evaluations.Total_Points, Evaluations.Comments
    FROM Locations INNER JOIN (((Visits INNER JOIN Evaluations ON Visits.Visit_ID
    = Evaluations.Visit_ID) INNER JOIN QuestionSet1 ON Evaluations.Question_ID =
    QuestionSet1.Question_ID) INNER JOIN PointRanges1 ON QuestionSet1.Group_ID =
    PointRanges1.Group_ID) ON Locations.Location_ID = Visits.Location_ID
    WHERE (((Locations.Location_Code)=22345) AND ((Visits.Visit_Date)=3/7/2005)
    AND ((QuestionSet1.Group_ID)=1) AND ((Visits.Confirmation_Number)<>0) AND
    ((Visits.Customer_ID)=1) AND ((Visits.Survey_ID)=8))
    ORDER BY Visits.Visit_Date;

    Working Query in Access
    SELECT Locations.Location_ID, Locations.Location_Code, Visits.Visit_Date,
    Visits.Visit_Time, PointRanges1.Group_Label, QuestionSet1.Question_MainText,
    QuestionSet1.A_Answer_Points, Evaluations.Total_Points, Evaluations.Comments
    FROM Locations INNER JOIN (((Visits INNER JOIN Evaluations ON Visits.Visit_ID
    = Evaluations.Visit_ID) INNER JOIN QuestionSet1 ON Evaluations.Question_ID =
    QuestionSet1.Question_ID) INNER JOIN PointRanges1 ON QuestionSet1.Group_ID =
    PointRanges1.Group_ID) ON Locations.Location_ID = Visits.Location_ID
    WHERE (((Locations.Location_Code)=22345) AND
    ((Visits.Visit_Date)=["Visit_Date"]) AND ((QuestionSet1.Group_ID)=1) AND
    ((Visits.Confirmation_Number)<>0) AND ((Visits.Customer_ID)=1) AND
    ((Visits.Survey_ID)=8))
    ORDER BY Visits.Visit_Date;

    As mentioned before, when I run the working query in Access and type in
    "3/7/2005" the correct data is return.

    Any help would be truly appreciated.

    Barry

    AHT Barry Guest

  2. Similar Questions and Discussions

    1. #40262 [NEW]: With or without snmp parameter, there is a shared access problem on conf files.
      From: yolcu at sst dot gen dot tr Operating system: Linux CentOs 4 PHP version: 5.2.0 PHP Bug Type: SNMP related Bug...
    2. MS Access d/b saved parameter query problem
      Trying to convert a page that adds records to a table. Have successfully done it (to a point) using the "saved parameter query". At first it...
    3. Problem of Date with MS Access
      I am trying to display the records which the date (the Name field is Period) are greater than today's date from MS Access. It works fine except that...
    4. Date Parameter For Saved Parameter Queries
      Hi again, I finally got to using saved parameter queries in my application (a big thank you to Bob Barrows for helping me with this). Currently...
    5. access db date parameter error
      Hello, I am using access database in aspx. I did something like this : .... currParam = new oleDbParameter("@create_date", OleDbType.DBTimeStamp)...
  3. #2

    Default Re: Access date parameter problem

    Try the CreateODBCDate function which will pass a DateTime object through your
    ODBC pipe. Another alternative that might work (can't remember if it's only
    Insert/Update vs. Where clause) is to surround it with single quotes even
    though it's a Date. Access has been know to "forgive" this minor violation. I
    think it might be for OLE rather than ODBC pipes though pipes. Also if your
    OLE, CreateODBCDate will NOT work instead you must use
    ####DateFormat(Visit_Date, "mm/dd/yyyy")###, extra #'s to wind up with a single
    # surrounding the date in the Where clause which is how Access really likes to
    see date constants.

    JMGibson3 Guest

  4. #3

    Default Re: Access date parameter problem

    TheCreateODBCDate worked! Thank you very much. All I did was change the SQL
    state to read ((Visits.Visit_Date)=#CreateODBCDate(The_Date)#) and the page
    worked correctly.

    Thank you very much for all of your help.

    Barry

    AHT Barry Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139