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

  1. #1

    Default Searching Dates

    Hi Guys

    I'm having a problem retriving dates when i use this query:
    <cfif Form.TxtDate GT "">
    <cfif Form.FindDate EQ "EQUALS">
    <cfset WhereClause = WhereClause & " and O_Date = " &
    CreateODBCDate(form.TxtDate)>
    <cfelseif Form.FindDate EQ "AFTER">
    <cfset WhereClause = WhereClause & " and O_Date > " &
    CreateODBCDate(form.TxtDate)>
    <cfelseif Form.FindDate EQ "BEFORE">
    <cfset WhereClause = WhereClause & " and O_Date < " &
    CreateODBCDate(form.TxtDate)>
    </cfif>
    </cfif>

    When a type a date, it doesnt bring nothing.

    Thank you and waiting for further answers

    []'s
    Alvaro Neto
    [email]alvaro_galdino@msn.com[/email]
    [email]alvaro_galdino@earthlink.net[/email]


    Supercyberal Guest

  2. Similar Questions and Discussions

    1. WE KNOW EXACTLY WHAT YOU'RE SEARCHING FOR!
      :disgust; I am addressing a forum made up of people young enough to be my children and grandchildren - I'm 73, have significant problems, none life...
    2. name searching
      Hello, I want to search for a name in a mysql database. Name-searching can be tricky. Let's say I want to find "Boer". This should match "de...
    3. Searching on Dates in MySQL
      Hello, I have CFM pages with Searching on Dates in MySQL. As you know MySQL Dates are "yyyy-mm-dd" format. However, we want date entering formats...
    4. Searching in a ?second? adn 'third' datafile
      Hi, I have an application which has a main file (in Access) called ASSESSMENTS, which has a subsidiary file called ASSESSCHEM. ASSESSMENTS...
    5. searching files
      I must make a cd-rom with pdf's that must be opened with director. I know have a copy of acrobat reader on the cd. This way I always not the filepath...
  3. #2

    Default Re: Searching Dates

    You'd be better of using the DATEDIFF() function (assuming your database has
    one which it should).

    You code would look something like this:



    <cfif Form.FindDate EQ "EQUALS">
    <cfset WhereClause = WhereClause & " and DATEDIFF(d,O_Date," &
    CreateODBCDate(form.TxtDate) & " = 0">
    <cfelseif Form.FindDate EQ "AFTER">
    <cfset WhereClause = WhereClause & " and DATEDIFF(d,O_Date," &
    CreateODBCDate(form.TxtDate) & " < 0">
    <cfelseif Form.FindDate EQ "BEFORE">
    <cfset WhereClause = WhereClause & " and DATEDIFF(d,O_Date," &
    CreateODBCDate(form.TxtDate) & " > 0">
    </cfif>

    efecto747 Guest

  4. #3

    Default Re: Searching Dates

    I don't think you should be using the follwoing cfif, not really what you want
    to do
    <cfif Form.TxtDate GT "">

    Try
    <cfif Len(Trim(Form.TxtDate)>
    Or
    <cfif Form.TxtDate NEQ "">

    Have you dumped the complete query string to ensure it is being constructed
    correctly ?
    Does the O_Date column only contain dates or dates and Times ?

    Ken


    The ScareCrow 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