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

cf procs

Guest
Nov 13, 2008 Nov 13, 2008
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
806
Translate
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
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
Translate
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
> <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
Translate
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
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?
Translate
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
LATEST
createdate()
Translate
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