Is the code in the CFC doing anything obviously wrong (like formatting the date)?


On 9/06/2010 11:38 AM, Gavin Baumanis wrote:
Hi Mike I am NOT seeing your issue.

Here is the code I am using;
(I even changed the format slightly between the CFC and the CFM just
to ensure it was dumping correctly.)

<dateformatter.cfm>
I am in the CFM<br />
<hr />
<cfset thedate = createdate("2010","06","10") >

<cfdump var="#lsdateformat(thedate, 'dd/mmm/yyyy')#" /><br />
<cfdump var="#dateformat(thedate, 'dd/mmm/yyyy')#"  /> <br />
<hr />

<cfset myobj = createobject("component","/scribble/dateformatter")>
I am in the CFC<br />
<cfscript>
	myobj.fn_datedumper();
</cfscript>



<dateformatter.cfc>
<cfcomponent output="false">
	<cffunction name="fn_datedumper">
		<cfset thedate = createdate("2010","06","10") >

		<cfdump var="#lsdateformat(thedate, 'dd/mm/yyyy')#" /><br />
		<cfdump var="#dateformat(thedate, 'dd/mm/yyyy')#"  /> <br />
	</cffunction>
</cfcomponent>

and here is the output;

I am in the CFM
10/Jun/2010
10/Jun/2010
I am in the CFC
10/06/2010
10/06/2010


As a best guess - I would be looking at the code used to insert /
update date columns in the database.
As I said previously in this thread, we dateformat(thedate, "yyyy-mm-
dd") in all hand written SQL that inserts/updates to ensure it is
persisted correctly.
it was the ONLY way e could find to ensure valid dates everytime - and
we spent a substantial amunt of time on trying to work it out, prior
to going down that path.
There may well be an "easier" option - and we ust donlt know about
it... but at least we can (now) guarantee that all dates are correct
in our database.

Gavin.

On Jun 9, 11:13 am, Mike Kear <afpwebwo...@gmail.com> wrote:
  
Well i had to suck that back again and wished i could have completely
obliterated my previous email.   I had a mistake in the code i posted on my
example earlier.    But i have just found the exact scenario happening.

Inside my CFCs,  i think American dates are always assumed.   I am setting a
date in my bean.   Even if i specifically set it using the code i quoted in
my last email  ( i.e. PosBean.setTransDate( createdate("2010","06","10") )
 for 10th June)   if i immediately output the date I get a different result
to what i get if i have it in a regular .cfm file.

<cfdump var="#lsdateformat(posbean.getTransDate(), 'dd/mmm/yyyy')#" />
<cfdump var="#dateformat(posbean.getTransDate(), 'dd/mmm/yyyy')#"  />

This code in a .cfm file outputs two showing 10 June.   If i output from a
.cfc it shows the first as 10 June, and the second as 6 October.

So unless i'm mistaken, I get a different result in a .cfm page than i get
if i output from a cfc.  The trouble is, it's the .cfc that is causing the
problem because its the cfc that creates the insert statement to the
database.

 This is proving to be a particularly elusive problem.  But since we use
dates to select records for a whole host of reports,  it's essential that i
sort it out.

Cheers
Mike Kear
Windsor, NSW, Australia
Adobe Certified Advanced ColdFusion Developer
AFP Webworkshttp://afpwebworks.com
ColdFusion 9 Enterprise, PHP, ASP, ASP.NET hosting from AUD$15/month



On Wed, Jun 9, 2010 at 10:33 AM, Dale Fraser <d...@fraser.id.au> wrote:
    
 Its working
      
    
createDate(year, month, day)
      
    
2010,10,06 is 6th of October.
      
    
Regards
      
    
Dale Fraser
      
    
http://dale.fraser.id.au
      
    
http://cfmldocs.com
      
    
http://learncf.com
      
    
http://flexcf.com
      
    
*From:* cfaussie@googlegroups.com [mailto:cfaussie@googlegroups.com] *On
Behalf Of *Mike Kear
*Sent:* Wednesday, 9 June 2010 10:30 AM
*To:* cfaussie@googlegroups.com
*Subject:* Re: [cfaussie] Re: Odd date behaviour - CF9/SQLServer2005
      
    
Believe it or not, I'm still worrying away at this date issue.    I dont
understand ColdFusion's insistence that we have to use American dates.
(This is CF9 Enterprise by the way)
      
    
I create a date object,  using the following:
      
    
createdate("2010","10","06")   which is supposed to be year, month, day in
that order.    Then when i output the date in the next line it shows that
date as 06/Oct/2010
      
    
It doesn't seem to make any difference whether i set a locale or not.
It's nothing to do with dateformat,  the problem here is that I'm creating a
date using year-month-day and it's understanding it as year-day-month.
 HUH??
      
    
Here is the actual code:
      
    
<cfset testdate = createdate("2010","10","06") />
      
    
<cfoutput>
      
    
<p>test date is  #testdate# : #dateformat(testdate, "dd/mmm/yyyy")# </p>
      
    
</cfoutput>
      
    
The result i get is this:
      
    
*test date is {ts '2010-10-06 00:00:00'} : 06/Oct/2010*
      
    
Can someone else please run this code on their CF9 and see if they get the
same result?   That way i can know if this is being caused by something in
the environment here.
      
    
Cheers
Mike Kear
Windsor, NSW, Australia
Adobe Certified Advanced ColdFusion Developer
AFP Webworks
http://afpwebworks.com
ColdFusion 9 Enterprise, PHP, ASP, ASP.NET hosting from AUD$15/month
      
    
On Tue, Jun 8, 2010 at 4:44 PM, Scott Thornton <
scott.thorn...@hnehealth.nsw.gov.au> wrote:
      
    
IMO, Set Langauge seems a bit... obtuse?
      
    
SET LANGUAGE DMY seems more appropriate, especially if you are giong to
enter it into every sproc.
      
    
cheers,
      
    
--
You received this message because you are subscribed to the Google Groups
"cfaussie" group.
To post to this group, send email to cfaussie@googlegroups.com.
To unsubscribe from this group, send email to
cfaussie+unsubscr...@googlegroups.com<cfaussie%2bunsubscr...@googlegroups.com>
.
For more options, visit this group at
http://groups.google.com/group/cfaussie?hl=en.
      
    
  --
You received this message because you are subscribed to the Google Groups
"cfaussie" group.
To post to this group, send email to cfaussie@googlegroups.com.
To unsubscribe from this group, send email to
cfaussie+unsubscr...@googlegroups.com<cfaussie%2bunsubscr...@googlegroups.com>
.
For more options, visit this group at
http://groups.google.com/group/cfaussie?hl=en.
      
--
Cheers
Mike Kear
Windsor, NSW, Australia
Adobe Certified Advanced ColdFusion Developer
AFP Webworkshttp://afpwebworks.com
ColdFusion 9 Enterprise, PHP, ASP, ASP.NET hosting from AUD$15/month
    
  

--
You received this message because you are subscribed to the Google Groups "cfaussie" group.
To post to this group, send email to cfaus...@googlegroups.com.
To unsubscribe from this group, send email to cfaussie+unsubscr...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/cfaussie?hl=en.

Reply via email to