Skip to main content
Inspiring
February 21, 2025
Answered

Dates not formatting correctly since update to CF 2023 (found solution)

  • February 21, 2025
  • 2 replies
  • 882 views

My CF host just did a server update to CF 2023. I spent all day fixing scope issues, but that wasn't too hard.

I noticed that my pages are showing weird dates. For instance in the MySQL database, this date shows as: 2023-05-15 00:00:00, But it displays as: 5/135/2023

 

The code to display that date is #DateFormat(Born,("M/D/YYYY"))#

 

Figured out what the issue was... D is days from the first of the year and d is days fo the month. When did this change?

    Correct answer Charlie Arehart

    The change regarding D meaning day of year in dateFormat functions was introduced (unexpectedly) in cf2021. So you must be migrating from cf2018 or earlier. Some good news: Adobe offered a JVM arg that would switch it back to ignoring the case of that "d". See the cf docs on the dateFormat function. 

     

    Or yes, you can change your code. I did a blog post the week this was introduced, and it some folks shared regex search strings for different major editors, to help there. I also offer the jvm arg and how to apply it as well as more on the change :

    https://www.carehart.org/blog/2020/11/24/breaking_change_in_cf2021_dateformat_D_vs_d

     

    As for your work to change scopes, I'll point out that while it's good to be done, you could have avoided it. This was a change introduced to both cf2023 AND cf2021 last march. More in a couple of blog posts that may help you:

     

    https://www.carehart.org/blog/2024/3/12/cf_updates_march_2024_possible_breaking_change

     

    https://www.carehart.org/blog/2024/7/18/dont_miss_helpful_feature_identify_implicit_scopes

     

    And as long as you're migrating beware of another important breaking change introduced in an update last June. I have posts on that there as well, from June and July. See the calendar offered in my blog site. 

     

    Finally, if you'd like to stay more up to date on such matters, I do blog about each update (to cf and to Java)--including extra info not offered by Adobe, and you can subscribe to my blog via a simple form offered there.

     

    Let us know if the first point above gets you going. 

    2 replies

    Charlie Arehart
    Charlie ArehartCorrect answer
    Community Expert
    February 22, 2025

    The change regarding D meaning day of year in dateFormat functions was introduced (unexpectedly) in cf2021. So you must be migrating from cf2018 or earlier. Some good news: Adobe offered a JVM arg that would switch it back to ignoring the case of that "d". See the cf docs on the dateFormat function. 

     

    Or yes, you can change your code. I did a blog post the week this was introduced, and it some folks shared regex search strings for different major editors, to help there. I also offer the jvm arg and how to apply it as well as more on the change :

    https://www.carehart.org/blog/2020/11/24/breaking_change_in_cf2021_dateformat_D_vs_d

     

    As for your work to change scopes, I'll point out that while it's good to be done, you could have avoided it. This was a change introduced to both cf2023 AND cf2021 last march. More in a couple of blog posts that may help you:

     

    https://www.carehart.org/blog/2024/3/12/cf_updates_march_2024_possible_breaking_change

     

    https://www.carehart.org/blog/2024/7/18/dont_miss_helpful_feature_identify_implicit_scopes

     

    And as long as you're migrating beware of another important breaking change introduced in an update last June. I have posts on that there as well, from June and July. See the calendar offered in my blog site. 

     

    Finally, if you'd like to stay more up to date on such matters, I do blog about each update (to cf and to Java)--including extra info not offered by Adobe, and you can subscribe to my blog via a simple form offered there.

     

    Let us know if the first point above gets you going. 

    /Charlie (troubleshooter, carehart. org)
    Inspiring
    February 22, 2025

    Yeah, my host just updated to the newest version of MySQL and CF 2023 (from 2018). I had source files for all the code locally and was able to do a find replace to fix all the instances that were messed up. The scope is taking a little longer because I have to find where it breaks and fix it. When I had my first CF class ages ago, he did talk about putting FORM. and URL. to scope the variables, but I guess I got lazy and wrote a bunch of code that wasn't scoped. It worked before without doing it so I didn't do it. Another instance where lazyness came back to bite me later. Oh well, it will only take about 8 hours work to get all of them fixed.

     

    Thanks for the links, I will subscribe.

    -K

    Charlie Arehart
    Community Expert
    February 22, 2025

    Thanks for the clarifications. I'd be surprised, though, that a host would not implement the jvm arg for dateFormat. Otherwise there will indeed be tremendous pain for most of their users on such a cf instance: and it can be devastating in also messing up db data and more. Can you share what host it is?

     

    As for the searchimplicitscopes issue, it's more understandable that hosts may opt not to implement that jvm arg, if they feel the tradeoff of security trumps compatibility. Even so, they should still help people to know that the app-level setting exists, because again the compatibility impact can be very significant for most apps. You're definitely not alone or even in a minority of people who didn't worry about scoping issues, as long as their code "worked". Even people writing code today could easily fall into that...unless their cf instance has this update and have not implemented either of those two mitigations. But even for those who do can use that patch to log the continued "implicit scope" use, as I discuss in the July blog post.

     

    But what doesn't kill us makes us stronger. Keep on with your workout! 🙂 

    /Charlie (troubleshooter, carehart. org)
    Community Expert
    February 22, 2025

    I think it's always been this way. The metacharacters (d, m, y) have always had different meanings when capitalized. However, I guess it's possible that some database drivers didn't honor those meanings. Anyway, look at the docs for dateFormat and LSDateFormat in the CF documentation.

     

    Dave Watts, Eidolon LLC