Whatever message this page gives is out now! Go check it out!

DateFormat function in ColdFusion (2021 release)

Last update:
May 18, 2026

Problem

In Adobe ColdFusion (2021 release), the mask D in date formatting functions, such as, DateFormat has been fixed to return the day of year. Since this can cause a few backward-compatibility issues, we've added a flag in jvm.config, the details of which are explained below.
For more information on this behavior, see the following:

Solution

We've added a JVM flag -Dcoldfusion.datemask.useDasdayofmonth. It defaults to false but when set to true and the mask contains D (uppercase D), the mask treats the value as d (lowercase d), day of the month. Hence, dateformat(now(), "mm-D-yyyy")  is the same as dateformat(now(), "mm-d-yyyy") when flag is set to true. By default, an uppercase D is used to specify Day of the year. 
For example, if the flag is set to False, and you run the snippet below, you get the following output.
<cfscript> 
    writeOutput(dateformat(now(), "mm-D-yyyy") & "<br/>") 
    writeOutput(dateformat(now(), "mm-DD-yyyy") & "<br/>") 
</cfscript>
OUTPUT
12-337-2020

12-337-2020
The uppercase D represents the day as the number of the day in the year (out of 365).
If the flag is set to True, and you run the snippet below, you get the following output.
<cfscript> 
    writeOutput(dateformat(now(), "mm-D-yyyy") & "<br/>") 
    writeOutput(dateformat(now(), "mm-DD-yyyy") & "<br/>") 
</cfscript>
OUTPUT
12-2-2020

12-2-2020

Share this page

Was this page helpful?
We're glad. Tell us how this page helped.
We're sorry. Can you tell us what didn't work for you?
Thank you for your feedback. Your response will help improve this page.

On this page