House of Fusion
Search over 2,500 ColdFusion resources here
  
Home of the ColdFusion Community

Mailing Lists
Home /  Groups /  ColdFusion Talk (CF-Talk)

createodbcdatetime change in ColdFusion 9?

  << Previous Post |  RSS |  Sort Oldest First |  Sort Latest First |  Subscribe to this Group Next >> 
Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Tony Paolillo
04/11/2012 12:20 PM

Hi, im stuck on a problem that i just cannot seem to figure out. I have a script that recieves popsts from the paypal IPN. This is my code for decoding the date/time: <cfif isdefined("form.payment_date")>   <cfset payment_date=urldecode(form.payment_date)>      <cfset dl = len(payment_date)>      <cfset cut = dl - 3>      <cfset paymentdate_temp=removechars(payment_date,cut,4)>        <cfset paymentdate = #createodbcdatetime(paymentdate_temp)#> </cfif> The script works fine in CF7 and 8 but kicks an error in CF9. I use cfcatch to snag the error. The error is this: Error at decoding the payment_date, Expression, , 08:38:49 Apr 11, 2012 is an invalid date or time string. I cannot figure out what to do to save my live. Can someone please help? Thanks Tony

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Russ Michaels
04/11/2012 12:31 PM

Tony, which line does that error occur on ? the error doesn't really make sense with the code supplied as the only line where you are doing anything with  payment_date is <cfset payment_date=urldecode(form.payment_date)> and this is not doing anything date/time related. Are you sure this error is not occuring elsewhere or that you are referencing payment_date somewhere rather than paymentdate_temp ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Tony Paolillo
04/11/2012 01:32 PM

----- Excess quoted text cut - see Original Post for more ----- The error occors on the line with createodbcdatetime. I added in a cffile to write soemthing to a file at each line for me to trace where the error occored and it made it all the way to the createodbcdatetime line and then kicked the error.. It doesent make sense to me why on CF9 but not any previous versions.

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Cameron Childress
04/11/2012 01:12 PM

I saw the same thing Russ saw in your code.  The variable "payment_date" and "paymentdate" are named similarly, but are not the same. The error appears to be thrown on "payment_date", which doesn't appear to interact with createodbcdatetime() in your example code at all. -Cameron ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Claude_Schnéegans
04/11/2012 01:17 PM

Are you using CFFORM? I never use it, but I kind of remember there is something special witf input fields containing "_date".

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Tony Paolillo
04/11/2012 01:33 PM

> Are you using CFFORM? > I never use it, but I kind of remember there is something special witf > input fields containing "_date". The data is actually being posted back from paypal. Paypal posts to my page with all the transaction vars and i parse them. The script was created by a much more advanced coder than myself and i cant seem to find the problem now.

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Claude_Schnéegans
04/11/2012 01:42 PM

>>The data is actually being posted back from paypal. Ok, I see. Well the problem is that CF is not able to parse the date in the format supplied by Paypal. Personally, I use createODBCDateTime(Now()) to register the date time. It will be the time related to your sever instead of Paypal's one, but it should be accurate enough.

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Russ Michaels
04/11/2012 01:47 PM

turn on FULL debug output in your cfadmin and it should give you more detail as well as exact line number for the error, in fact a try/catch will do this also. no create a page with a form that posts the exact same data as paypal, and you can use this to debug rather than waiting for paypal. On Wed, Apr 11, 2012 at 6:41 PM, <> wrote: ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Tony Paolillo
04/11/2012 01:53 PM

----- Excess quoted text cut - see Original Post for more ----- Actually, this is the error from cftry/cfcatch: Error at decoding the payment_date, Expression, , 08:38:49 Apr 11, 2012 is an invalid date or time string. I did create a local script and recieved the same error, then i removed the time from the paypal post string and it worked. What i dont understand is why does it work on CF8 and not CF9. Also, lets say i can remove the time from the post, how can i do that? which line? I tried createodbcdate and still got the same error. Thanks

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Tony Paolillo
04/11/2012 01:54 PM

>  >>The data is actually being posted back from paypal. > > Ok, I see. Well the problem is that CF is not able to parse the date > in the format supplied by Paypal. > Personally, I use createODBCDateTime(Now()) to register the date time. > It will be the time related to your sever instead of Paypal's one, but > it should be accurate enough. Ill try that also.. thanks

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
morgan lindley
04/11/2012 02:36 PM

What is the actual content of the form.payment_date coming from PayPal? It should be something like '08:38:49 Apr 11, 2012 PDT'. The code below works just fine on that value on CF9 in my testing environment. Without the ' PDT' part, the code tries to run createodbcdatetime() on '08:38:49 Apr 11, ', which fails. ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Tony Paolillo
04/11/2012 02:48 PM

----- Excess quoted text cut - see Original Post for more ----- Im sending this in my test and it fails:  "08:38:49 April 11, 2012 EST". If i take out the time and have this "Apr 11, 2012 EST" It works. I noticed that the date im trying to create an odbc datetiime on is "08:38:49 Apr 11, 2012" and its failing.. That still has the time in it but not the EST. So are you saying i should take off the "cut" in my code and leave the EST on? Thanks

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
morgan lindley
04/11/2012 03:26 PM

What I was saying is, I tested the actual code you originally posted on CF9 with 08:38:49 Apr 11, 2012 PDT as the input and it works fine. I was trying to verify that the data you're working with has the timezone on the end, since the "cut" portion of the code is designed to remove that, and will remove needed data if your input doesn't include it. I just tested again with 08:38:49 April 11, 2012 EST, and your original code also works. Removing the "cut" won't fix your trouble, because 08:38:49 April 11, 2012 EST isn't a valid date/time string for CF. I used this for my testing: <form method="post"> <input type="text" name="payment_date" value="08:38:49 Apr 11, 2012  EST " /> <button>Post</button> </form> <cfif isdefined("form.payment_date")>        <cfset payment_date=urldecode(form.payment_date)>        <cfset dl = len(payment_date)>        <cfset cut = dl - 3>        <cfset paymentdate_temp=removechars(payment_date,cut,4)>       <cfset paymentdate = #createodbcdatetime(paymentdate_temp)#> <cfdump var="#paymentdate#"> </cfif> I noticed that the date im trying to create an odbc datetiime on is > "08:38:49 Apr 11, 2012" and its failing.. That still has the time in it but > not the EST. > This should work fine: <cfdump var="#createodbcdatetime('08:38:49 Apr 11, 2012')#"> You may be running into an ambiguity issue with CF being type-less. Createodbcdatetime() wants a DateTime object but will accept a string CF thinks it can parse. For my test environment, CF can parse the string you have, but it seems your server environment can't. I can't say for sure why, and getting into the server settings isn't really something I have a lot of experience with.

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Tony Paolillo
04/11/2012 03:46 PM

Thank you for your help. I just added this code into a simple cf page: <cfset paymentdate = #createodbcdatetime('08:38:49 April 11, 2012 EST')#> and i get an error just loading the page: "Parameter validation error for the CREATEODBCDATETIME function. The value of parameter 1, which is currently 08:38:49 April 11, 2012 EST, must be a class java.util.Date value." Must be on the server end because it works accross my testing server also. The server is a hosting server in the UK so i dont know if they have something setup differently. Ill have to contact them. Thanks for your help. Tony

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
morgan lindley
04/11/2012 03:54 PM

That needs to be: <cfset paymentdate = #createodbcdatetime('08:38:49 April 11, 2012')#> The time zone on the end is invalid in CF. > <cfset paymentdate = #createodbcdatetime('08:38:49 April 11, 2012 EST')#>


<< Previous Thread Today's Threads Next Thread >>

Search cf-talk

May 25, 2013

<<   <   Today   >   >>
Su Mo Tu We Th Fr Sa
       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   

Designer, Developer and mobile workflow conference