Copy link to clipboard
Copied
They dropped a servder upgrade on me and now (after a little more than 10 years) this code doesn't work. Any ideas what I can change it to?
#dateformat(News_Date, 'dddd mmmm dd, yyyy')#
HELP! Please,
And thank you.
Copy link to clipboard
Copied
What version of ColdFusion are you now running? What is the exact error you are getting?
I just ran this on CFFiddle and it runs fine.
<cfset News_Date = now()>
<cfoutput>
#dateformat(News_Date, 'dddd mmmm dd, yyyy')#
</cfoutput>
Copy link to clipboard
Copied
They offer fabulous error reporting...
The web site you are accessing has experienced an unexpected error.
Please contact the website administrator.
You can see it in action here:
Northwest Association of Slot Track Enthusiasts : Results (naste.org)
I'm awaiting info on what version they are running.
Thank you very much.
Copy link to clipboard
Copied
A page will load without error with that line commented out:
Copy link to clipboard
Copied
Have you verified that #News_Date# is what you expect it to be?
You could wrap the offending line of code in a CFTRY and email yourself the full error so you don't have to wait on the host.
<cftry>
#dateFormat(News_Date,'dddd mmmm dd, yyyy')#
<cfcatch type="any">
<cfmail to="me@sample.com" from="myserver@sample.com" subject="Error MEssage" typ="html">
<cfdump var="#News_Date#">
<cfdump var="#cfcatch#">
</cfmail>
</cfcatch>
</cftry>
Copy link to clipboard
Copied
The site has been perfectly stable for more than 10 years with that code on multiple pages.
Copy link to clipboard
Copied
CF10
Copy link to clipboard
Copied
They made a change see this link:
https://helpx.adobe.com/coldfusion/kb/dateformat-function-coldfusion-2021.html
Copy link to clipboard
Copied
So this is a server fix rather than a code change?
Copy link to clipboard
Copied
Yes, it's a server change.
Dave Watts, Eidolon LLC
Copy link to clipboard
Copied
Well, you're not using a capital D as in the article. Have you tried using a different mask? Verified the #News_Date#?
Copy link to clipboard
Copied
Are you suggesting this:
#dateformat(News_Date, 'DDDD mmmm DD, yyyy')#
How many capital D's?
Copy link to clipboard
Copied
Wasn't suggesting that, no. Just pointing out the tech note seemed to talk about using capital D whereas you were not using that.
What I was suggesting is that you try a different mask just to see if it works. And, still no word on verifying the #news_date#. It's possible you may have a malformed date in your data?
Copy link to clipboard
Copied
No, it's not possible. The site has a very active calendar that has been in operation for more than 10 years. The change happened as soon as they moved the site to a new server.
Copy link to clipboard
Copied
did you apply the update in the link i provided?
Copy link to clipboard
Copied
It's not my server, I sent them the info.
Copy link to clipboard
Copied
They dropped a servder upgrade on me and now (after a little more than 10 years) this code doesn't work. Any ideas what I can change it to?
#dateformat(News_Date, 'dddd mmmm dd, yyyy')#
By @Monte28993316xw9z
Yes, here is an idea. Locate the line of code that contains
dateformat(News_Date, 'dddd mmmm dd, yyyy')
Add the following validation code just before that line:
<cfset newsDateAsString=toString(News_Date)>
<cfif isDate(News_Date)>
<cfset News_Date=parseDateTime(newsDateAsString)>
<cfelse>
<cflog file="News_Date_Check" text="The value of the 'News_Date' variable is currently '#newsDateAsString#', which does not represent a valid date. Location: #getTemplatePath()#" type="error">
Sorry, error. The error has been logged. We're working on it.
<cfabort>
</cfif>
If there is a wrong value for date, an error will be logged in News_Date_Check.log
Copy link to clipboard
Copied
they changed the way the DD or dd is ready its day in the year ( vs what it was i believe). he needs to patch the server or come up with another way to code that output not using CF. Everything is in the link I posted.
Copy link to clipboard
Copied
@rickmaz , "dd" was used, instead of "DD", as @sdsinc_pmascari said. So I wonder whether patching the server is relevant. In any case, @Monte28993316xw9z mentioned being on CF10.
@Monte28993316xw9z , are you really on CF10? Run the following as a test CFM page. What does it give you?
My ColdFusion version: <cfoutput>#server.coldfusion.productversion#</cfoutput>
Copy link to clipboard
Copied
Copy link to clipboard
Copied
@Monte28993316xw9z , did you do the validation test I suggested?
Copy link to clipboard
Copied
Copy link to clipboard
Copied
I, too, asked about the possibility of an invalid date coming through and, instead of validating, you simply said it was impossible because nothing had changed (famous last words). @BKBK is now also asking you to validate the dates and I don't see that you've done that? Why not? Even if you think it's impossible, humor us. Otherwise, it's "impossible" to eliminate that as the potential issue.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
It sure would be nice to know exactly what was different with the server implementation.
Dave Watts, Eidolon LLC