SELECT query Error, possible date problem?

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

  1. #1

    Default SELECT query Error, possible date problem?

    Hello, I have what I thought was a fairly straight forward date based query
    that is returning an error I cant seem to get past. Here is my scenario: I was
    handed this code what was supposedly functional on a CF 4.5 box running SQL
    server 7. Due to a hosting provider change, the platform was upgraded to CF7
    and SQL2k sp3. Now the code doesnt work. There are 2 formfields being passed
    that contain valid dates in mm/yy/dddd format to the following query. the date
    adds are so that I can search 3 days before and after the submitted form field
    dates. <cfset today_int=#CreateODBCDate(Now())#> <cfset s_date_low =
    #dateAdd('d', -3, form.start_dt)#> <cfset e_date_high = #dateAdd('d', 3,
    form.end_dt)#> <cfquery name='get_getaways' datasource='#application.dsn#'>
    SELECT * FROM tblgetaway2 WHERE start_dt > #s_date_low# AND end_dt <
    #e_date_high# AND active=1 AND booked=0 AND (hotwk=0 OR hotwk=2) AND
    start_dt>#today_int# ORDER BY start_dt </cfquery> This Query always results in
    Error Executing Database Query. [Macromedia][SQLServer JDBC
    Driver][SQLServer]Syntax error converting datetime from character string. My
    database field types are set as datetime. Can anyone help? I'm at a loss at
    this point...

    rowbeast Guest

  2. Similar Questions and Discussions

    1. Problem using SELECT TOP and ORDER BY together in a query
      SQL is based on set theory. You are ordering the resultset by the StoryDate. So you have 6 articles at the top of the list. How is the database...
    2. date query problem, date in variable
      I am using the following query : $query_archief = "SELECT * FROM vacatures where dd_eind_plaatsing < $dd_eind_plaatsing_archief1" note:...
    3. update and insert query error, but select works ok.
      :rose; Any ideas spring to mind about the following issue? I'm getting an error trying to run an Update or Insert query. I can run a Select...
    4. IIF in Select Query Error
      Hello, I need to create a query with a date calculation of elapsed minutes. And, I have made this work. Now I find that some of the...
    5. problem with the select query
      Hi people, this is my first mail to the group. i am having a problem with the select query. There are a few values in few columns of a table with...
  3. #2

    Default Re: SELECT query Error, possible date problem?

    Depending on how your dates are defined in your database, you may need to treat them as strings. For example,
    WHERE start_dt > '#s_date_low# ' ...
    jdeline Guest

  4. #3

    Default Re: SELECT query Error, possible date problem?

    try the <CFQUERYPARAM CFSQLTYPE='CF_SQL_DATE' VALUE='##'> It will format the
    date for the appropriate datasource you are using (thus you needn't worry if it
    is DB2's 'yyyy-mm-dd' or Oracle's 'dd-mmm-yy' etc). If this fails and you have
    the ability, verify that the database is indeed using DATES in these fields (if
    not, you can have issues with > or < on text fields that are holding dates -- I
    have seen issues on this esp in MS Access); get them changed to dates or
    decimals or something that does not do a dictionary attack for gt and lt...
    <cfquery name='get_getaways' datasource='#application.dsn#'> SELECT * FROM
    tblgetaway2 WHERE start_dt > <CFQUERYPARAM CFSQLTYPE='CF_SQL_DATE'
    VALUE='#s_date_low#'> AND end_dt < <CFQUERYPARAM CFSQLTYPE='CF_SQL_DATE'
    VALUE='#e_date_high#'> AND active=1 AND booked=0 AND (hotwk=0 OR hotwk=2) AND
    start_dt> <CFQUERYPARAM CFSQLTYPE='CF_SQL_DATE' VALUE='#today_int#'> ORDER BY
    start_dt </cfquery>

    tanging 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