• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

cf procs

Guest
Nov 13, 2008 Nov 13, 2008

Copy link to clipboard

Copied

Hi i am tring to pass a date to ms sql via cfproc i have add in param as

<cfprocparam type="In" cfsqltype="CF_SQL_DateTime" dbvarname="InvoiceDate" value="#DateFormat(CreateODBCDate(form.txtInvoiceDate), "dd-mm-yyyy")#" null="No">

but i am getting a varchar to datetime exeption

any ideas?
TOPICS
Advanced techniques

Views

785

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Nov 13, 2008 Nov 13, 2008

Copy link to clipboard

Copied

Try this
<cfprocparam type="In" cfsqltype="CF_SQL_TIMESTAMP" value="#DateFormat(form.txtInvoiceDate, 'dd-mm-yyyy')#" null="No">

Note:
The MS SQL server datatype DATETIME maps to CF_SQL_TIMESTAMP.
Removed CreateODBCDate function call
Corrected nested quotes in value attribute contents
The dbvarname attribute is no longer supported
You may also try a date format string 'yyyy-mm-dd' or 'mm-dd-yyyy' depending on the configuration of your SQL server

http://msdn.microsoft.com/en-us/library/ms189491.aspx

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 13, 2008 Nov 13, 2008

Copy link to clipboard

Copied

> <cfprocparam type="In" cfsqltype="CF_SQL_DateTime" dbvarname="InvoiceDate"
> value="#DateFormat(CreateODBCDate(form.txtInvoiceDate), "dd-mm-yyyy")#"
> null="No">
>
> but i am getting a varchar to datetime exeption

If it's after a date, why are you passing it a string? dateFormat() is for
converting a date into a string, which you'd only generally do when
outputting the date for a human.

Pass the DB a date.

PS: the dbvarname attribute of <cfprocparam> is not supported on most
recent versions of CF. This is probably not relevant to your situation,
but it's worth bearing in mind.

--
Adam

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Nov 13, 2008 Nov 13, 2008

Copy link to clipboard

Copied

ok thanks,

but i need to pass the format from a form field

dd-mm-yyyy
so whats the best way to convert this to a date?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Nov 13, 2008 Nov 13, 2008

Copy link to clipboard

Copied

LATEST
createdate()

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation