CREATEODBCDATE

I have a field named docDate that is defined as date time in sql table.
I want to query the table and find all records for docDate >= 05/18/2009 and docDate <= 05/24/2009
If I have this in my query, is it correct ? It seems to run fine thru analyzer but there are too many records for me to cound manuall to verify.
WHERE CONVERT(CHAR(10), docDate, 101) between #createodbcdate(lastWeek)# and #CreateODBCDate(todaysDate)#, where lastWeek is 05/18/2009 and todaysDate is 05/24/2009

I would expect that the convert() function is unnecessary.  If the field is defiend as a datetime field than passing in datetime values should match without any conversion requred.
so it will just be Where docDate between odbccretedate(lastweek) and odbcreatedate(todaydate) ?
As to passing datetimevalues while createodbcdate() will do that, using <cfqueryparam value="#lastWeek#" cfsqltype="cf_sql_date"> is considered a much better way to do this as it also protects one from sql injection as well as creating a datatime value
Using this method, would it be
Where docDate betewwn  <cfqueryparam value="#lastWeek#" cfsqltype="cf_sql_date"> and  <cfqueryparam value="#todaysdate#" cfsqltype="cf_sql_date"> ?

Similar Messages

  • Help-ColdFusion - enabling a user to search for records in a database by entering a startand end date - (CREATEODBCDATE)

    I want to enable a user to enter a start and end date to
    define the period they want to search for records of members who
    joined on certain dates. Funny thing is...I've got it to work half
    of the time. For e.g. I have 4 records between 26/10/2005 and
    1/08/2006. When I enter 01/01/2005 as startDate and 31/08/2006 as
    endDate, I get the 4 records. However, if I alter the endDate to
    01/09/2006 I get every record in the database!!!??? Why's this? I
    can't get my head around it!
    Here's my code:
    First the code for the form the user input the search
    criteria on:
    <html>
    <body>
    <FORM action="memberJDateSearch.cfm" method="post">
    <p>Start Date: <input type="text"
    name="startDate">
    <br>End Date: <input type="text" name="endDate">
    <input type="reset" value="Clear">
    <input type="submit" value="Submit">
    </FORM>
    </body>
    </html>
    Simple enough. Now the code for the process and display page:
    <html>
    <body>
    <cfquery name="memberJDateSearch"
    datasource="jpkelle2-access">
    SELECT *
    From members
    WHERE ((joinDate BETWEEN #CreateODBCDate(startDate)# AND
    #CreateODBCDate(endDate)#))
    </cfquery>
    <table border=1 bgcolor="beige" cellpadding="3"
    cellspacing="0">
    <tr>
    <th>Member ID</th>
    <th>Name</th>
    <th>Sex</th>
    <th>Date of Birth</th>
    <th>Address</th>
    <th>Email</th>
    <th>Date Joined</th>
    </tr>
    <CFOUTPUT Query="memberJDateSearch">
    <tr>
    <td><center>#memberID#<center></td>
    <td width="15%">#forename# #initial#
    #surname#</td>
    <td>#sex#</td>
    <td width="10%">#disp('#dob#')#</td>
    <td>#address#, #town#, #county#, #postCode#</td>
    <td>#email#</td>
    <td width="10%">#disp('#joinDate#')#</td>
    </tr>
    </CFOUTPUT>
    </table>
    <hr><p>End of members list.</p>
    </body>
    </html>
    any ideas? please help me.

    Try formatting your dates first (before the CreateODBCDate
    call). I just tried this on my test page and it worked properly. I
    removed the DateFormat calls, keeping the dates in your format and
    it didn't work. See if something like the following will help:
    <cfset startDate =
    DateFormat("31/01/2006","dd/mm/yyyy")/>
    <cfset endDate =
    DateFormat("01/09/2007","dd/mm/yyyy")/>
    <cfquery name="memberJDateSearch"
    datasource="jpkelle2-access">
    SELECT *
    From members
    WHERE ((joinDate BETWEEN #CreateODBCDate(startDate)# AND
    #CreateODBCDate(endDate)#))
    </cfquery>

  • Coldfusion - search parameters - CreateODBCDate

    I want to enable a user to enter a start and end date to
    define the period they want to search for records of members who
    joined on certain dates. Funny thing is...I've got it to work half
    of the time. For e.g. I have 4 records between 26/10/2005 and
    1/08/2006. When I enter 01/01/2005 as startDate and 31/08/2006 as
    endDate, I get the 4 records. However, if I alter the endDate to
    01/09/2006 I get every record in the database!!!??? Why's this? I
    can't get my head around it!
    Here's my code:
    First the code for the form the user input the search
    criteria on:
    <html>
    <body>
    <FORM action="memberJDateSearch.cfm" method="post">
    <p>Start Date: <input type="text"
    name="startDate">
    <br>End Date: <input type="text" name="endDate">
    <input type="reset" value="Clear">
    <input type="submit" value="Submit">
    </FORM>
    </body>
    </html>
    Simple enough. Now the code for the process and display page:
    <html>
    <body>
    <cfquery name="memberJDateSearch"
    datasource="jpkelle2-access">
    SELECT *
    From members
    WHERE ((joinDate BETWEEN #CreateODBCDate(startDate)# AND
    #CreateODBCDate(endDate)#))
    </cfquery>
    <table border=1 bgcolor="beige" cellpadding="3"
    cellspacing="0">
    <tr>
    <th>Member ID</th>
    <th>Name</th>
    <th>Sex</th>
    <th>Date of Birth</th>
    <th>Address</th>
    <th>Email</th>
    <th>Date Joined</th>
    </tr>
    <CFOUTPUT Query="memberJDateSearch">
    <tr>
    <td><center>#memberID#<center></td>
    <td width="15%">#forename# #initial#
    #surname#</td>
    <td>#sex#</td>
    <td width="10%">#disp('#dob#')#</td>
    <td>#address#, #town#, #county#, #postCode#</td>
    <td>#email#</td>
    <td width="10%">#disp('#joinDate#')#</td>
    </tr>
    </CFOUTPUT>
    </table>
    <hr><p>End of members list.</p>
    </body>
    </html>
    any ideas? please help me.

    Do you have debugging turned on? What does the actual sql
    look like?
    As an aside, you don't need the double brackets in your where
    clause.

  • CreateODBCDate and cfqueryparam with cf_sql_date

    Hi all.
    I've got a form that's accepting the following date formats
    (YYYY-MM-DD and MM-DD-YYYY).
    Just wondering if it's even necessary to use the
    CreateODBDate when I'm passing in the dates in my <cfquery>
    using a queryparam with a type of cf_sql_date?
    From what I understand cf_sql_date will recognize either of
    the two formats and properly create the ODBC date the way it's
    supposed to, but I can't find any resources that says this. Anyone
    know this for sure or not, and maybe have a reference I can point
    my team in the right direction?
    Thanks.

    Unless there is a known difference in how the two parse date
    strings, I would say no. Both parse a string and return a properly
    formatted date/time object. I strongly suspect they both use the
    same parsing method behind the scenes anyway.
    As an aside, MM-DD-YYYY can be interpreted multiple ways. But
    most likely both CreateODBCDate and cfqueryparam will interpret the
    value the same way.. for right or wrong ;-)

  • Error while updating a record in MS Access

    Im new to coldfusion and am running into a problem while
    trying to update a record in a MS Access table.
    I have a MS Access table where the primary key is a
    auto-number long integer field named jobid.
    I have an edit form where info can be changed then saved. A
    hidden form field named jobid holds the records primary key field
    value for the record being edited. When submitted this is what
    happens:
    I use a basic SQL UPDATE statement but I get the error "Data
    type mismatch in criteria expression"
    Some code:
    <cfset nJobId=Int(Val(FORM.jobid))>
    *dont know if i need the above line but using #FORM.jobid#
    in the WHERE clause below didnt work either
    <cfquery datasource="lrs">
    UPDATE jobs SET
    status='#FORM.status#',
    offer='#FORM.offer#',
    postdate="#CreateODBCDate(FORM.postdate)#",
    jobtype=#FORM.jobtype#,
    jobtitle='#FORM.jobtitle#',
    ..etc...
    WHERE jobid=#nJobId#
    The WHERE clause is where the error occurs with "Data type
    mismatch in criteria expression"
    After a few times with that i changed the where clause to
    simply "WHERE jobid=1" as this record id does exist, but it has the
    same error.
    I then tried changing the where clause to
    WHERE jobid=<cfqueryparam cfsqltype="cf_sql_bigint"
    value="#FORM.jobid#">
    and there it "appears" to work, but the record is not
    actually updated. No changes are made to the table though no error
    is thrown.
    Im missing something here... why wont the record update
    ?

    The data type mismatch isn't necessarily in your where
    clause. I'm guessing that it's the quotes around the create
    odbcdate function.
    use of cfqueryparam will solve a lot of these problems for
    you.

  • How to handle blank dates

    In my cfform, the user can select a starting and ending date
    to search, a text field to search, or both the dates and text field
    to search. Here is what I have :
    <tr>
    <td align="center" colspan="2">
    <font size="3" face="Arial, Helvetica, sans-serif"
    color="003366">
    <b>From Date:</b></font>
    <input type="text" size=11 name="fromDate_value"
    value="">
    <a
    href="javascript:show_calendar4('document.getPSDocs.fromDate_value',
    document.getPSDocs.fromDate_value.value)">
    <img src="calendar.gif" width="25" height="25" border="0"
    alt="Click here to Date Stamp"></a>
    <font size="3" face="Arial, Helvetica, sans-serif"
    color="003366">
    <b>To Date:</b></font>
    <input type="text" size=11 name="toDate_value"
    value="">
    <a
    href="javascript:show_calendar4('document.getPSDocs.toDate_value',
    document.getPSDocs.toDate_value.value)">
    <img src="calendar.gif" width="25" height="25" border="0"
    alt="Click here to Date Stamp"></a>
    </td>
    </tr>
    <tr>
    <td colspan="2"> 
    </td>
    </tr>
    <tr>
    <td colspan="2" align="center">
    <img height="3" src="../images/rule_navyH4W760Solid.gif"
    width="759" border="0">
    </td>
    </tr>
    <tr>
    <td colspan="2"> 
    </td>
    </tr>
    <tr>
    <td align="center" colspan="2">
    <font size="3" face="Arial, Helvetica, sans-serif"
    color="003366">
    <b>Pick Request
    Number: </b></font>
    <select name="search_type">
    <option value="Contains">Contains</option>
    <option value="Begins With">Begins With</option>
    <option value="Ends With">Ends With</option>
    <option value="Is">Is</option>
    <option value="Is Not">Is Not</option>
    <option value="Before">Before</option>
    <option value="After">After</option>
    </select>
    <input type="text" name="prNumber" required="yes"
    message="Request Number Must Be Entered for Search">
    </td>
    </tr>
    <tr>
    In my action page, I build the query based on the search
    criteria. Here is what I have so far :
    <cfquery name="getPRNum" datasource="docuTrack">
    SELECT *
    FROM dbo.psFileInventory
    <cfif form.search_type is "Contains" and form.prNumber is
    not "">
    Where dbo.psFileInventory.prNumber like '%#form.prNumber#%'
    <cfelseif form.search_type is "Begins With" and
    form.prNumber is not "">
    Where dbo.psFileInventory.prNumber like '#form.prNumber#%'
    <cfelseif form.search_type is "Ends With" and
    form.prNumber is not "">
    Where dbo.psFileInventory.prNumber like '%#form.prNumber#'
    <cfelseif form.search_type is "Is" and form.prNumber is
    not "">
    Where dbo.psFileInventory.prNumber = '#form.prNumber#'
    <cfelseif form.search_type is "Is Not" and form.prNumber
    is not "">
    Where dbo.psFileInventory.prNumber <>
    '#form.prNumber#'
    <cfelseif form.search_type is "Before" and form.prNumber
    is not "">
    Where dbo.psFileInventory.prNumber <= '#form.prNumber#'
    <cfelseif form.search_type is "After" and form.prNumber
    is not "">
    Where dbo.psFileInventory.prNumber >= '#form.prNumber#'
    </cfif>
    <cfif form.fromDate_value is not " " and form.prNumber is
    not " ">
    And fileDate between #CreateODBCDate(form.fromDate_value)#
    and #CreateODBCDate(form.toDate_value)#
    <cfelseif form.fromDate_value is not " " and
    form.prNumber is " ">
    Where fileDate between #CreateODBCDate(form.fromDate_value)#
    and #CreateODBCDate(form.toDate_value)#
    </cfif>
    order by prNumber
    </cfquery>
    I basically see to see what was select so that I can use the
    like, not like, etc..Then I check to see if there is a date value
    so that I can know whether to use AND in the select statement.
    If both the field and dates are selected, then it would be
    select where xxxx and date.......
    If the field is selected only, then it would be select where
    xxxx
    If the date is selected only, then it would be select where
    date xxxxxx
    The problem is when I check for date is " " in the cfif
    statement, keep getting error about null values. So I check for
    date is null or date is not null, but that still does not work. It
    works find when I check for both the field and date as not " ",
    then I can use AND, but when I try to check for any other
    combinataion, I get the NULL error.
    How can I fix this ?

    trojnfn wrote:
    > Thanks for the reply.
    >
    > Does this function work like isDefined ?
    >
    > To check for the existence of a date so that I can build
    my query, I would
    > have :
    > <cfif isDate(start_date) and field is not " ">
    > And date between .xxxxxx
    > <cfelse>
    > <cfif isDate(start_date) and field is " ">
    > where date between xxxxx
    > </cfquery>
    >
    > Is this how it works ?
    >
    now that's a bit of convoluted logic there...
    how about:
    <cfif isdate(yourdate)>
    <cfif yourfield is " ">
    <cfelse>
    </cfif>
    </cfif>
    you can add a <cfelse> in the outer cfif if you need to
    have a separate
    condition for yourdate NTO being a date
    another thing i noticed: what's up with " "? i mean, why a
    space between
    the quotes? you know that a blank form field does NOT have a
    space as
    value, right? so if you are checking that a user has entered
    something
    in a field or not, and you are using <cfif somefiled is "
    ">, if a user
    did not fill in that field your cfif will return FALSE; if
    you used
    <cfif somefield is ""> it would have returned TRUE.
    i suggest instead of checking for a blank value of a filed,
    check the
    length of that value instead: <cfif len(trim(somefield))
    is 0>
    hth
    Azadi Saryev
    Sabai-dee.com
    http://www.sabai-dee.com

  • Another Error Executing Database Query.

    I am getting this error.
    12:40:54.054 - Database Exception - in
    C:\CFusionMX7\wwwroot\Author\dropdown2\EmployeeAddAction.cfm : line
    26
    Error Executing Database Query.
    i have added extra fields in the mdb and added extra code to
    the form page and the action page.
    i am getting this error still.
    this is how i broke it down.
    If I run my 2 files EmployeeAddForm.cfm and
    EmployeeAddAction.cfm
    I get this error:
    NOTE: if i take out the comments from the code and ignore the
    new fields added to the db it works fine!!!!!
    The web site you are accessing has experienced an unexpected
    error.
    Please contact the website administrator.
    The following information is meant for the website developer
    for debugging purposes.
    Error Occurred While Processing Request
    Error Executing Database Query.
    [Macromedia][SequeLink JDBC Driver][ODBC
    Socket][Microsoft][ODBC Microsoft Access Driver] Syntax error in
    INSERT INTO statement.
    Resources:
    Enable Robust Exception Information to provide greater detail
    about the source of errors. In the Administrator, click Debugging
    & Logging > Debugging Settings, and select the Robust
    Exception Information option.
    Check the ColdFusion documentation to verify that you are
    using the correct syntax.
    Search the Knowledge Base to find a solution to your problem.
    Browser Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;
    SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)
    Remote Address 127.0.0.1
    Referrer
    http://127.0.0.1:8500/Author/dropdown2/EmployeeAddForm.cfm
    Date/Time 06-Jun-07 12:40 PM
    NOTE: if i take out the comments from the code and ignore the
    new fields added to the db it works fine!!!!!

    Try using '###CreateODBCDate(Form.DateOfBirth)###'. Access is
    strange on
    handling dates. It has a been a while since I have used
    Access so it could
    be as simple as wrapping it single quotes as well. I am
    assuming the
    "<!-----------" wasn't intended, but I could be wrong.
    Bryan Ashcraft (remove brain to reply)
    Web Application Developer
    Wright Medical Technology, Inc.
    Macromedia Certified Dreamweaver Developer
    Adobe Community Expert (DW) ::
    http://www.adobe.com/communities/experts/
    "Coldfusionstudent" <[email protected]>
    wrote in message
    news:[email protected]...
    >I am getting this error.
    > 12:40:54.054 - Database Exception - in
    >
    C:\CFusionMX7\wwwroot\Author\dropdown2\EmployeeAddAction.cfm : line
    26
    > Error Executing Database Query.
    >
    > i have added extra fields in the mdb and added extra
    code to the form page
    > and
    > the action page.
    > i am getting this error still.
    > this is how i broke it down.
    >
    > If I run my 2 files EmployeeAddForm.cfm and
    EmployeeAddAction.cfm
    > I get this error:
    >
    > The web site you are accessing has experienced an
    unexpected error.
    > Please contact the website administrator.
    >
    > The following information is meant for the website
    developer for debugging
    > purposes.
    >
    > Error Occurred While Processing Request
    > Error Executing Database Query.
    > [Macromedia][SequeLink JDBC Driver][ODBC
    Socket][Microsoft][ODBC Microsoft
    > Access Driver] Syntax error in INSERT INTO statement.
    >
    >
    > Resources:
    > Enable Robust Exception Information to provide greater
    detail about the
    > source
    > of errors. In the Administrator, click Debugging &
    Logging > Debugging
    > Settings, and select the Robust Exception Information
    option.
    > Check the ColdFusion documentation to verify that you
    are using the
    > correct
    > syntax.
    > Search the Knowledge Base to find a solution to your
    problem.
    >
    >
    > Browser Mozilla/4.0 (compatible; MSIE 6.0; Windows NT
    5.1; SV1; .NET CLR
    > 1.1.4322; .NET CLR 2.0.50727)
    > Remote Address 127.0.0.1
    > Referrer
    http://127.0.0.1:8500/Author/dropdown2/EmployeeAddForm.cfm
    > Date/Time 06-Jun-07 12:40 PM
    >
    >
    >
    > EmployeeAddForm.cfm
    >
    > <cfquery name="GetCompanies"
    > datasource="#Request.MainDSN#">
    > SELECT
    > CompanyID,
    > CompanyName
    > FROM
    > Company
    > ORDER BY
    > CompanyName
    > </cfquery>
    >
    > <html>
    > <head>
    > <title>ColdFusion MX Bible</title>
    > <link rel="stylesheet" href="styles.css">
    > </head>
    >
    > <body>
    >
    > <h1> </h1>
    >
    > <table>
    > <cfform action="EmployeeAddAction.cfm"
    method="POST">
    >
    > <tr>
    > <td>Company</td>
    > <td>
    > <cfselect name="CompanyID"
    > size="1"
    > query="GetCompanies"
    > value="CompanyID"
    > display="CompanyName"
    > required="Yes"
    > message="Please select a Company."></cfselect>
    > </td>
    > </tr>
    >
    > <tr>
    > <td>SSN</td>
    > <td>
    > <cfinput type="Text"
    > name="SSN"
    > message="Please enter the employee's Social Security
    Number."
    > validate="social_security_number"
    > required="Yes"
    > size="12"
    > maxlength="11">
    > </td>
    > </tr>
    >
    > <tr>
    > <td>First Name</td>
    > <td>
    > <cfinput type="Text"
    > name="Firstname"
    > message="Please enter the employee's first name."
    > required="Yes"
    > size="22"
    > maxlength="20">
    > </td>
    > </tr>
    >
    > <tr>
    > <td>Last Name</td>
    > <td>
    > <cfinput type="Text"
    > name="Lastname"
    > message="Please enter the employee's last name."
    > required="Yes"
    > size="22"
    > maxlength="20">
    > </td>
    > </tr>
    >
    > <tr>
    > <td>Salary</td>
    > <td>
    > <cfinput type="Text"
    > name="Salary"
    > message="Please enter a valid salary."
    > validate="float"
    > required="Yes"
    > size="22"
    > maxlength="20">
    > </td>
    > </tr>
    >
    > <tr>
    > <td>DOB</td>
    > <td>
    > <cfinput type="Text"
    > name="DateOfBirth"
    > message="Please enter a valid date of birth in the
    format mm/dd/yyyy"
    > validate="date"
    > required="Yes"
    > size="11"
    > maxlength="10">
    > </td>
    > </tr><!-------------
    > <tr>
    > <td>device_typ</td>
    > <td>
    > <cfinput type="Text"
    > name="device_typ"
    > message="Please enter the employee's device_typ."
    > required="Yes"
    > size="22"
    > maxlength="20">
    > </td>
    > </tr><tr>
    > <td>device_Email</td>
    > <td>
    > <cfinput type="Text"
    > name="device_Email"
    > message="Please enter the employee's device_Email."
    > required="Yes"
    > size="22"
    > maxlength="20">
    > </td>
    > </tr><tr>
    > <td>Work_email</td>
    > <td>
    > <cfinput type="Text"
    > name="Work_email"
    > message="Please enter the employee's Work_email."
    > required="Yes"
    > size="22"
    > maxlength="20">
    > </td>
    > </tr><tr>
    > <td>Pin_Number</td>
    > <td>
    > <cfinput type="Text"
    > name="Pin_Number"
    > message="Please enter the employee's Pin_Number."
    > required="Yes"
    > size="22"
    > maxlength="20">
    > </td>
    > </tr>------------------>
    > <tr>
    > <td> </td>
    > <td>
    > <input type="submit" value="Add to Database">
    > </td>
    > </tr>
    >
    > </cfform>
    > </table>
    >
    > </body>
    > </html>
    > ---------------------------
    > EmployeeAddAction.cfm
    >
    > <cfquery name="InsertEmployee"
    > datasource="#Request.MainDSN#">
    > INSERT INTO Employee(
    > SSN,
    > CompanyID,
    > Firstname,
    > Lastname,
    > Salary,
    > DateOfBirth<!----------,
    > device_typ,
    > device_Email,
    > Work_email,
    > Pin_Number-------------->
    >
    > )
    > VALUES (
    > '#Trim(Form.SSN)#',
    > #Val(Form.CompanyID)#,
    > '#Trim(Form.Firstname)#',
    > '#Trim(Form.Lastname)#',
    > #Val(Form.Salary)#,
    > #CreateODBCDate(Form.DateOfBirth)#<!-----------,
    > '#Trim(Form.device_typ)#',
    > '#Trim(Form.device_Email)#',
    > '#Trim(Form.Work_email)#',
    > '#Trim(Form.Pin_Number)#'------------------>
    > )
    > </cfquery>
    >
    > <cfmail
    to="#Form.Firstname#.#Form.Lastname#@somewhere.com"
    > from="[email protected]"
    > subject="Welcome to your new company!">
    > Welcome to your new company, #Form.Firstname#
    #Form.Lastname#!
    > </cfmail>
    > <!----
    > <cflocation url="EmployeeList.cfm">----->
    >

  • cfif problem

    I'm trying to evalute whether a user is uploading an MS Word
    file with spaces in the filename. We cannot have spaces in
    filenames on our Internet site. So, basically, on the form page
    there is a field with a browse box for user to select their file.
    It's is passed to the action page; here's the code.
    I've used the same <cfif> statement on a bare bones
    page & it does work but for some reason it is not working on
    this page. I'm wondering if there's code on this page preventing it
    from being evaluted.
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0
    Transitional//EN">
    <html>
    <head>
    <title>Human Resources Job Bank Form
    Action</title>
    </head>
    <body>
    <!-- Check for spaces in filename -->
    <cfif form.positionfile CONTAINS " ">
    The document you attached to this position contains spaces in
    the filename. We cannot post documents containing spaces or special
    characters on the Internet.<br><br>
    <b>How to fix the problem
    &#8212;</b><br><br>
    <OL>
    <LI>Please rename the original file without using
    spaces or punctuation. <br><br>The following characters
    are approved for file naming on the Web.
    <ul type="square">
    <li>Letters A-Z and a-z
    <li>Numerals 0-9
    <li>Dashes ( - )
    <li>Underscores ( _ )
    </ul>
    <br>
    <LI>Use your web browser's <b>Back</b>
    button to return to <b>Post a Position in the Job
    Bank</b> and reattach the position using the "Upload
    Document" box.<br><br>
    <LI>Resubmit the position using a compatible filename.
    <BR><BR>
    </OL><BR>
    <cfelse>
    <!--- capture the autonumber position id for use in the
    uploads table --->
    <cflock name="#CreateUUID()#" timeout="20">
    <cftransaction>
    <!--- Insert the position info into the main positions
    table --->
    <CFQUERY NAME="Insertposition"
    DATASOURCE="#Application.DSN#">
    Insert into positions
    (title, medcenterID, otherlocation, areaID, carelineID,
    grade, emailID, opendate, closedate)
    VALUES
    ('#FORM.title#','#FORM.medcenterid#','#FORM.otherlocation#','#FORM.areaID#','#FORM.carelin eid#','#FORM.grade#','#FORM.emailID#','#FORM.opendate#','#FORM.closedate#')
    </CFQUERY>
    <cfquery DATASOURCE="#Application.DSN#"
    name="getLastID">
    SELECT MAX(positionID) as lastID
    FROM positions
    </cfquery>
    </cftransaction>
    </cflock>
    <!--- Confirm to the user that the position was
    successfully added, allow them to add another or see the master
    list --->
    <cfoutput>#DateFormat(createodbcdate(Now()),'mm/dd/yyyy')#
    <br>
    Position ID #getlastid.lastid#: #Form.Title#</cfoutput>
    has been added to the HR Job Bank.<br><br>
    <!--- upload the file to the directory and only accept
    word docs --->
    <cffile action="UPLOAD" filefield="positionfile"
    destination="#application.uploaddirectory#"
    nameconflict="MAKEUNIQUE">
    <!--- Fill in the uploads table with the name and path for
    the uploaded file --->
    <CFQUERY NAME="CreateDocumentRecord"
    DATASOURCE="#Application.DSN#">
    INSERT INTO Uploads (positionID, Date_Published, File_Name,
    Upload_Path)
    VALUES
    ('#VAL(getlastid.lastid)#',#createodbcdate(Now())#,'#FILE.ClientFile#','#FILE.ServerFile# ')
    </CFQUERY>
    </cfif>
    <!--- Grab Medical Center Name --->
    <CFQUERY name="getmedicalcenter"
    DATASOURCE="#Application.DSN#">
    SELECT medcenterID, medcenter_name
    FROM location
    WHERE medcenterID = #form.medcenterID#
    </CFQUERY>
    <!--- Grab Area Name --->
    <CFQUERY name="getarea" DATASOURCE="#Application.DSN#">
    SELECT areaID, area_name
    FROM areaofconsideration
    WHERE areaID = #form.areaID#
    </CFQUERY>
    <!--- Grab Care Line Name--->
    <CFQUERY name="getcareline"
    DATASOURCE="#Application.DSN#">
    SELECT carelineID, careline_name
    FROM carelines
    WHERE carelineID = #form.carelineID#
    </CFQUERY>
    </cfif>
    </body>
    </html>

    The form page has sent you a temporary filename that does not
    contain the space - therefore, it passes the CFIF test. A
    workaround would be to do a CFDIRECTORY ACTION="list" to obtain the
    filename of the most recent timestamp and do a CFFILE
    ACTION="rename" if you find a space in the filename.

  • Combining data from SQL query

    Hoping there is a SQL guru out there that can help me with this
    I have two tables that I want to pull data from and display a report, based on a particular date range, for this example let's say 08/01/2011 to 08/31/2011
    In one table there would be an affiliate ID - AFF_UID and also the date and a counter for that date, IMP_COUNTER , now there may only be a few records not every day might be covered, say
    TABLE IMP
    date,aff_uid,imp_counter
    08/01/2011,999,2000
    08/02/2011,999,2050
    08/20/2011,999,2030
    etc
    I then have another date, similar set up only there are multiple records in here for a single day, again not all days covered, I would need to total up each row for each day to get a count. So it might be:
    TABLE LEAD
    date,aff_uid
    08/01/2011,999
    08/01/2011,999
    08/01/2011,999
    08/01/2011,999
    08/12/2011,999
    So we have different dates covered, sometimes the same date, I need the counter from the first table, and from the second table I need to add them up for a total, and then display any date that has a value and put both counter and lead count together
    Result from above
    date,imp total,lead total
    08/01/2011,2000,4
    08/02/2011,2050,0
    08/12,2011,0,1
    08/20/2011,2030,0
    I am sure there must be a SQL command that can gel all of this together with some grouping? Last thing I need is a ton of SQL statements in a loop!
    My alternative is to add a counter to the IMP table for each lead, so every time I update the lead table with a record, I will also update the counter, but that's unncessary storage of data I already have an an extra update statement that I might be able to do without, but maybe it would make generating reports faster, just pulling to counters with no 'addition' required.
    Appreciate any feedback
    Thanks
    Mark

    Well I thought that I had this one up and running, but once it went into production I found that it didn't give the desired results.
    I have an account that has 3 'tracking'/aff accounts, so what it's doing is giving out 3 lines for each date rather than join them together into one. The values are also incorrect, I'm still trying to figure out just where it's even getting those numbers, I manually added up the numbers in the dbase and it didn't match
    Here's the command
    <CFQUERY name="GetStats" DATASOURCE="#datasource#">
    SELECT
    COALESCE(IMP.imp_date, LEAD.lead_date) AS report_date
    , COALESCE(IMP.imp_counter,0) AS imp_counter
    , COALESCE(LEAD.lead_count,0) AS lead_count
    , COALESCE(LEAD.lead_aff_payment,0) AS lead_aff_payment
    FROM
    SELECT
    imp_date
    , imp_counter
    FROM impressions
    WHERE imp_date BETWEEN #createODBCdate(form_from)# AND #createODBCdate(form_to)#
    <CFIF #val(ListGetAt(form_aff_UID,1))# IS "3">
    AND imp_aff_uid  IN (SELECT aff_uid FROM aff WHERE aff_master_uid = #session.aff_uid#)
    <CFELSEIF #val(ListGetAt(form_aff_UID,1))# IS "2">
    AND imp_aff_uid  = #val(ListGetAt(form_aff_UID,2))#
    <CFELSE>
    AND imp_aff_uid  IN (SELECT aff_uid FROM aff WHERE aff_sub_uid = #val(ListGetAt(form_aff_uid,2))# AND aff_master_uid = #session.aff_uid#)
    </CFIF>
    ) AS IMP
    FULL OUTER JOIN
    SELECT
    lead_date, COUNT(*) AS lead_count, SUM(lead_aff_payment) AS lead_aff_payment
    FROM leads
    WHERE lead_date BETWEEN #createODBCdate(form_from)# AND #createODBCdate(form_to)#
    AND lead_data_status = 1
    <CFIF #val(ListGetAt(form_aff_UID,1))# IS "3">
    AND lead_aff_uid  IN (SELECT aff_uid FROM aff WHERE aff_master_uid = #session.aff_uid#)
    <CFELSEIF #ListGetAt(form_aff_UID,1)# IS "2">
    AND lead_aff_uid = #val(ListGetAt(form_aff_uid,2))#
    <CFELSE>
    AND lead_aff_uid  IN (SELECT aff_uid FROM aff WHERE aff_sub_uid = #val(ListGetAt(form_aff_uid,2))# AND aff_master_uid = #session.aff_uid#)
    </CFIF>
    GROUP BY lead_date
    ) AS LEAD
    ON ( IMP.imp_date = LEAD.lead_date )
    ORDER BY report_date;
    </CFQUERY>
    and here are the results
    TRAFFIC REPORT: 01/01/2012 - 01/21/2012
    All Accounts
    Date
    Offers
    Served
    Total
    Leads
    Revenue
      01/19/2012
    249
    1
    $0.38       
      01/19/2012
    11
    1
    $0.38       
      01/19/2012
    30
    1
    $0.38       
      01/20/2012
    1,006
    7
    $2.66       
      01/20/2012
    40
    7
    $2.66       
      01/20/2012
    1,090
    7
    $2.66       
      01/21/2012
    582
    6
    $2.28       
      01/21/2012
    33
    6
    $2.28       
      01/21/2012
    515
    6
    $2.28       
    Total
    3,556
    42
    Sub-Total
    $15.96       
    Referral Revenue
    $0.00       
    Total
    $15.96  
    $15.96 is NOT correct, I need to find out whats going on there, but the other issue is look how it's duplicating the dates, it's one line for each account by the look of it
    Can anybody help! This SQL command already got a little beyond me
    Thanks
    Mark

  • Data type mismatch in criteria expression. What am I not seeing??

    Once again I'm stuck! I have included the query I'm trying to run below.  I have also indicated the data types of my fields.
    <cfquery name="qGetOrders" datasource="manna_premier">
    SELECT DISTINCT Count(ID) AS CountOfID,   - number
                                 TMName,   -text
                                 Sum(Quantity) AS SumOfQuantity,   - number
                                 Count(NewExisting) AS CountOfNewExisting -number
    FROM Users, Orders, ProductOrders
    WHERE SaleDate BETWEEN #CreateODBCDate(FORM.Start)# AND #CreateODBCDate(FORM.End)#
    GROUP BY UserZone, TMName
    </cfquery>
    When run it returns this error message....
    Error Executing Database Query.
    [Macromedia][SequeLink JDBC Driver][ODBC Socket][Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression.
    The error occurred in D:\Inetpub\mannapremier\zvp_report2.cfm: line 11
    9 :                     Count(NewExisting) AS CountOfNewExisting
    10 : FROM Users, Orders, ProductOrders
    11 : WHERE SaleDate BETWEEN #CreateODBCDate(FORM.Start)# AND #CreateODBCDate(FORM.End)#
    12 : GROUP BY UserZone, TMName
    13 : </cfquery>
    SQLSTATE
      22018
    SQL
       SELECT DISTINCT Count(ID) AS CountOfID, TMName, Sum(Quantity) AS SumOfQuantity, Count(NewExisting) AS CountOfNewExisting FROM Users, Orders, ProductOrders WHERE SaleDate BETWEEN {d '2009-10-01'} AND {d '2009-10-31'} GROUP BY UserZone, TMName
    VENDORERRORCODE
      -3030
    DATASOURCE
      manna_premier
    I use the where clause on several other pages and it works. I don't understand where my data type is mismatched.
    Can anyone point me in the right direction?

    4) If you indeed need to select from the 3 tables Users,
    Orders, ProductOrders, then you should qualify the columns
    names like this, Users.ID, productOrders.Quantity, and so
    on.
    You also need to join on the related columns. If you forget to do that the resultset will be a massive cartesian table (huge number of records):
    rows in Table1 * #rows in Table2 * #rows in Table3

  • Report data binding error with date values

    I have CF7.02 with a Microsoft Visual FoxPro 9.0 SP1 Database
    that I connect to using ODBC (FoxPro Driver 6.01.8630.01). I send
    my sql results to a CF Report Builder 7.02 PDF report and it works
    fine. If I dump the date values before I change them, they look
    like the following: {ts '2004-12-20 00:00:00'} . However I have
    tried a number of ways of manipulating the date before sending it
    to the report, but I continue to get errors. I don't care what
    format they go to the report in, since the report reformats them
    anyway. I checked to make sure that none of the dates were null.
    For example <cfset ReportQuery.PrcInputDate[lcCurRow] =
    CreateODBCDateTime(#ldCFPrcInputDate#) /> yields values in the
    {ts '2004-12-20 00:00:00'} format when I dump the query results to
    screen. Where:
    ldCFPrcInputDate = 12/20/2004
    CreateODBCDateTime(ldCFPrcInputDate) = {ts '2004-12-20
    00:00:00'}
    ReportQuery.PrcInputDate[lcCurRow] = {ts '2004-12-20
    00:00:00'}
    I get the error:
    Report data binding error Unable to get value for field
    'prcinputdate' of class 'java.util.Date'.
    coldfusion.runtime.OleDateTime -> Date
    Not using the CreateODBCDate function for example <cfset
    ReportQuery.PrcInputDate[lcCurRow] = #ldCFPrcInputDate# /> I
    get:
    Report data binding error Unable to get value for field
    'prcinputdate' of class 'java.util.Date'.
    java.lang.String -> Date
    Here are some of my failed attempts:
    <cfset ReportQuery.PrcInputDate[lcCurRow] =
    CreateODBCDateTime(#ldCFPrcInputDate#) />
    <cfset ReportQuery.PrcInputDate[lcCurRow] =
    #ldCFPrcInputDate# />
    <cfset ReportQuery.PrcInputDate[lcCurRow] =
    DateFormat(CreateODBCDate(#ldCFPrcInputDate#),'mm/dd/yyyy') />
    <cfset ReportQuery.PrcInputDate[lcCurRow] =
    CreateODBCDate(DateFormat(#ldCFPrcInputDate#,'mm/dd/yyyy') />
    <cfset ReportQuery.PrcInputDate[lcCurRow] =
    CreateODBCDate(DateFormat(#ldCFPrcInputDate#,'mm-dd-yyyy') />
    <cfset ReportQuery.PrcInputDate[lcCurRow] =
    Trim(createODBCDateTime(ldtmpdate)) />
    <cfset ReportQuery.PrcInputDate[lcCurRow] =
    CreateODBCDate({05-07-2006}) />
    <cfset ReportQuery.PrcInputDate[lcCurRow] =
    CreateODBCDate('{05-07-2006}') />
    <cfset ReportQuery.PrcInputDate[lcCurRow] =
    CreateODBCDate(05/07/2006) />
    <cfset ReportQuery.PrcInputDate[lcCurRow] =
    CreateODBCDate('05/07/2006')/>
    <cfset ReportQuery.PrcInputDate[lcCurRow] =
    CreateODBCDate(parseDateTime('05/07/2006')) />
    <cfset ReportQuery.PrcInputDate[lcCurRow] =
    parseDateTime(CreateODBCDateTime(05/07/2006)) />
    <cfset ReportQuery.PrcInputDate[lcCurRow] =
    parseDateTime(CreateODBCDateTime('#ldCFPrcInputDate#')) />
    <cfset ReportQuery.PrcInputDate[lcCurRow] = '{05-07-2006}'
    />
    <cfset ReportQuery.PrcInputDate[lcCurRow] = '{05/07/2006}'
    />
    <cfset ReportQuery.PrcInputDate[lcCurRow] = '05/07/2006'
    />
    I also did some googling without success. Any help is
    appreciated.

    You may want to make sure that the column is not included in
    the query variable list in your report cfr file.
    The newest version of the Report Builder, which may be
    installed on the server, no longer tolerates vars appearing in that
    list of they are not in the query itselft.

  • Syntax error in INSERT STATEMENT

    A problem on the date part of the query but why I don´t
    know, Thanks for any pointers,
    TIA
    <cfquery name="update1" datasource="trevor_SecurityDB">
    INSERT INTO imagesproducts
    (title, info, date)
    VALUES ( '#form.title#', '#form.info#', '#DateFormat(Now())#'
    </cfquery>
    Error Occurred While Processing Request
    Error Executing Database Query.
    [Macromedia][SequeLink JDBC Driver][ODBC
    Socket][Microsoft][ODBC Microsoft Access Driver] Syntax error in
    INSERT INTO statement.
    The error occurred in uploadmember.cfm: line 28
    26 : INSERT INTO imagesproducts
    27 : (title, info, date)
    28 : VALUES ( '#form.title#', '#form.info#',
    '#DateFormat(Now())#' )
    29 : </cfquery>
    30 :
    SQL INSERT INTO imagesproducts (title, info, date) VALUES (
    'News test', 'Testing news info', '12-Jul-07' )
    DATASOURCE trevor_SecurityDB
    VENDORERRORCODE -3502
    SQLSTATE 42000

    Perhaps it is a reserved word issue with the date column,
    since
    date is an ODBC Reserved Keyword. You might try enclosing it
    within brackets [ ].
    <cfquery name="update1" datasource="trevor_SecurityDB">
    INSERT INTO imagesproducts
    (title, info, [date])
    VALUES ( '#form.title#', '#form.info#', '#DateFormat(Now())#'
    </cfquery>
    Or, if that doesn't help, you might try using a cfqueryparam
    tag for the '#DateFormat(Now())#' value using a cfsqltype =
    "CF_SQL_TIMESTAMP" (assuming a date/time datatype on the column).
    Also, you might look into using one of the CreateODBCDateTime() or
    CreateODBCDate() functions.
    Phil

  • Problem with SELECT statement. What is wrong with it?

    Why is this query....
    <cfquery datasource="manna_premier" name="kit_report">
    SELECT Orders.ID,
           SaleDate,
           Orders.UserID,
        Distributor,
        DealerID,
        Variable,
        TerritoryManager,
        US_Dealers.ID,
           DealerName,
        DealerAddress,
        DealerCity,
        DealerState,
        DealerZIPCode,
        (SELECT SUM(Quantity)
         FROM ProductOrders PO
         WHERE PO.OrderID = Orders.ID) as totalProducts,    
    FROM Orders, US_Dealers
    WHERE US_Dealers.ID = DealerID AND SaleDate BETWEEN #CreateODBCDate(FORM.Start)# AND #CreateODBCDate(FORM.End)# AND Variable = '#Variable#'
    </cfquery>
    giving me this error message...
    Error Executing Database Query.
    [Macromedia][SequeLink JDBC Driver][ODBC Socket][Microsoft][ODBC Microsoft Access Driver] The SELECT statement includes a reserved word or an argument name that is misspelled or missing, or the punctuation is incorrect.
    The error occurred in D:\Inetpub\mannapremier\kit_report2.cfm: line 20
    18 :              WHERE PO.OrderID = Orders.ID) as totalProducts,        
    19 : FROM Orders, US_Dealers
    20 : WHERE US_Dealers.ID = DealerID AND SaleDate BETWEEN #CreateODBCDate(FORM.Start)# AND #CreateODBCDate(FORM.End)# AND Variable = '#Variable#'
    21 : </cfquery>
    22 :
    SQLSTATE
      42000
    SQL
       SELECT Orders.ID, SaleDate, Orders.UserID, Distributor, DealerID, Variable, TerritoryManager, US_Dealers.ID, DealerName, DealerAddress, DealerCity, DealerState, DealerZIPCode, (SELECT SUM(Quantity) FROM ProductOrders PO WHERE PO.OrderID = Orders.ID) as totalProducts, FROM Orders, US_Dealers WHERE US_Dealers.ID = DealerID AND SaleDate BETWEEN {d '2009-10-01'} AND {d '2009-10-31'} AND Variable = 'Chick Days pre-book'
    VENDORERRORCODE
      -3504
    DATASOURCE
      manna_premier
    Resources:
    I copied it from a different template where it works without error...
    <cfquery name="qZVPData" datasource="manna_premier">
    SELECT UserID,
           TMName,
        UserZone,
              (SELECT COUNT(*)
               FROM Sales_Calls
               WHERE Sales_Calls.UserID = u.UserID) as totalCalls,
        (SELECT COUNT(*)
         FROM Orders
         WHERE Orders.UserID = u.UserID) as totalOrders,
        (SELECT SUM(Quantity)
         FROM ProductOrders PO
         WHERE PO.UserID = u.UserID AND PO.NewExisting = 1) as newItems,
        (SELECT SUM(NewExisting)
         FROM  ProductOrders PO_
         WHERE PO_.UserID = u.UserID) as totalNew,
        SUM(totalOrders)/(totalCalls) AS closePerc
    FROM Users u
    WHERE UserZone = 'Central'
    GROUP BY UserZone, UserID, TMName
    </cfquery>
    What is the problem?

    It's hard to say: what's your request timeout set to?
    700-odd records is not much of a fetch for a decent DB, and I would not expect that to case the problem.  But then you're using Access which doesn't fit the description of "decent DB" (or "fit for purpose" or "intended for purpose"), so I guess all bets are off one that one.  If this query is slow when ONE request is asking for it, what is going to happen when it goes live and multiple requests are asking for it, along with all the other queries your site will want to run?  Access is not designed for this.  It will really struggle, and cause your site to run like a dog.  One that died serveral weeks ago.
    What else is on the template?  I presume you're doing something with the query once you fetch it, so could it be that code that's running slowly?  Have you taken any steps to isolate which part of the code is taking so long?
    How does the query perform if you take the subquery out of the select line?  Is there any other way of getting that data?  What subquery will be running once for every row of the result set... not very nice.
    Adam

  • Date woes

    I have a query that returns records when i do not use a where
    clause. I want to return records for a range of dates.
    I have used between and >= and <= but no records are
    returned. The dates are stored in an msacess table as long dates. I
    tried with single quote both on and off the dates - the code
    follows - thanks
    jim
    and btw the search on these forums returns an error message.
    anyone else have the same results?

    PaulH **AdobeCommunityExpert** wrote:
    > rockhiker wrote:
    >> I have used between and >= and <= but no
    records are returned. The
    >> dates are stored in an msacess table as long dates.
    I tried with
    >> single quote both on and off the dates - the code
    follows - thanks
    >
    > turn those strings into dates that access can handle
    either via
    > createdate() or createODBCdate() functions.
    >
    Or, best yet, <cfqueryparam...> tags with
    cfsqltype="cf_sql_date"
    parameters.

  • Baffled by date query

    It's been awhile since I've done any CF and I'm baffled by the results I'm getting. I want to select all the records where the date is greater than or equal to today. This is with CF8 and an Access database. There are records for 9/25 thru 9/30. I can't get the record for today to show.
    <cfset dateToday = createODBCDate(Now()) />
    <cfoutput>DateToday: #DateFormat(dateToday,'yyyy-mm-dd')#</cfoutput><br />
    <br />
    <cfquery datasource="survey" name="test">
              SELECT *
              FROM Images
              WHERE StartDate >= <cfqueryparam value="#DateToday#" cfsqltype="cf_sql_timestamp" />
    </cfquery>
    <cfoutput query="test">
    #startdate#<br />
    </cfoutput>
    DateToday: 2013-09-26
    Results:
      2013-09-27 00:00:00.0
      2013-09-29 00:00:00.0
      2013-09-28 00:00:00.0
      2013-09-30 00:00:00.0
    Furthermore, if I eliminate the GT sign and have "StartDate =" today, there are no results.

    Now() includes a time component.  If you want records from earlier today, you have to create a date variable with no time element.   CreateDate, Year(), Month() and Day() will come in handy.

Maybe you are looking for

  • Change field content of IDOC automatically

    Dear all, we have a little problem and I think that can be solved by changes incoming IDOCs. But I'm not that familiar with IDOCs, so my question: We get HR-Data from another system. Message Type: HRMD_A Basic Type: HRMD_A07 We want to change the pay

  • Error Loading xmlparserv2.jar

    Platform: NT4 SP5 Database: 8.1.6 When loading xmlparserv2.jar via loadjava, I'm getting an ORA-01401: inserted value too large for column. Command: loadjava -user eclipse/eclipse@bugs -r -v xmlparserv2.jar Errors: loading : oracle/xml/parser/v2/mesg

  • Error in materialized views

    during the materialized view creation. i am phasing the following error ERROR at line 12: ORA-12014: table 'mtest' does not contain a primary key constraint but the table does't have primary key. when i tried to add primary key to the table mtest .an

  • Can Time Machine Backup to the harddrive of another machine on the network?

    I have a PC on my wifi network with alot of spare room on the HD. i'd like to back up to it. Is this possible? How? thanks, rich

  • How to calculate the time between start trigger,first scan and first A/D in DAQ

    Environment: Labview 6.1, N6052E DAQ board(max scan rate=333KHz, max channel rate=333KHz, settling time=3.5usec+1LSB) I am using external scan clock 10K scan/s collecting data on 16 AI channels, and external channel clock 200KHz. Could show me how to