Skip to main content
Participating Frequently
November 19, 2010
Answered

Not sure how to acheive the result I need.

  • November 19, 2010
  • 2 replies
  • 567 views

Hi All,

I am not a very good programmer but I am learning so please bear with me.

My problem is I need to be able to create a page that we can imput two dates and get all items in our database that are equal to or between the imputted dates and be outputted to the page.

The sql portion is not my issue but I am not sure as to how to create the page with the to date boxes.

As it stands now I have the page created but it is retreving all items from my table and just outputting it to a smiple grid and the table has way to many entries for this to be managable.

So if anyone can help me or point me in the right direction that would be great.

Thnaks

Pat

    This topic has been closed for replies.
    Correct answer ilssac

    Basis of a form.

    <form action="..." method="post">

       <input type="text" name="aDate">

       <input type="text" name="bDate">

       <input type="submit">

    </form>

    Basis of a SQL clause

    <cfquery datasource="..." name="aRecSet">

      SELECT aField,bField,cField

      FROM aTable

      WHERE aDateField BETWEEN

              <cfqueryparam value="#form.aDate#" cfsqltype="cf_sql_date"> AND

              <cfqueryparam value="#form.bDate#" cfsqltype="cf_sql_date">

    </cfquery>

    There is much left for you to learn and figure out to make a function and professional page.  But that should at least get you close to returning results.

    2 replies

    Inspiring
    November 19, 2010

    There's a great big section of the docs that goes through how to use forms, which is pretty essential to know thoroughly if one is doing any CF programming:

    http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec22c24-7ffe.html

    Most of the answers to questions you're gonna come up against can probably be answered before they need to be asked if you have a read through that, and experiment with what they suggest.

    --

    Adam

    ilssac
    Inspiring
    November 19, 2010

    So where do you need the help?

    How to make an HTML form?

    How to use dates entered into an HTML form in a SQL where clause?

    How to make an fancy shamancy DTHML,Flash and|or AJAX date picker to augment an HTML form?

    Something else?

    Hpmac2Author
    Participating Frequently
    November 19, 2010

    Hi

    Thanks for the quick answer

    I guess I need help in make the form and also the dates in the sql where clause.

    Thanks

    Pat

    ilssac
    ilssacCorrect answer
    Inspiring
    November 19, 2010

    Basis of a form.

    <form action="..." method="post">

       <input type="text" name="aDate">

       <input type="text" name="bDate">

       <input type="submit">

    </form>

    Basis of a SQL clause

    <cfquery datasource="..." name="aRecSet">

      SELECT aField,bField,cField

      FROM aTable

      WHERE aDateField BETWEEN

              <cfqueryparam value="#form.aDate#" cfsqltype="cf_sql_date"> AND

              <cfqueryparam value="#form.bDate#" cfsqltype="cf_sql_date">

    </cfquery>

    There is much left for you to learn and figure out to make a function and professional page.  But that should at least get you close to returning results.