Hi all
I’ve problems using the DateAdd function.
Sourcecode:
<cfoutput>#GetLocale()#</cfoutput><br>
<cfoutput><cfset SetLocale('swiss german')></cfoutput>
<cfoutput>#GetLocale()#</cfoutput><br>
<cfset j = 5>
<cfset start_date = "10.11.2014">
<cfloop index = "LopingLouis" from = "1" to = "#j#">
<cfset start_date = #LSDateFormat(DateAdd('m', +1, start_date))#>
<cfset start_date = #LSDateFormat(start_date, "01.mm.yyyy")#>
<cfoutput>#start_date#</cfoutput><br>
<cfset j = j - 1>
</cfloop>
The result is:
01.11.2014
01.02.2014
01.02.2014
01.02.2014
01.02.2014
If i do it like this:
<cfoutput>#GetLocale()#</cfoutput><br>
<cfoutput><cfset SetLocale('swiss german')></cfoutput>
<cfoutput>#GetLocale()#</cfoutput><br>
<cfset j = 5>
<cfset start_date = lsparseDateTime(date="11.10.2014", format="dd.mm.yyyy")>
<cfloop index = "LopingLouis" from = "1" to = "#j#">
<cfset start_date = #LSDateFormat(DateAdd('m', +1, start_date))#>
<cfset start_date = #LSDateFormat(start_date, "01.mm.yyyy")#>
<cfoutput>#start_date#</cfoutput><br>
<cfset j = j - 1>
</cfloop>
The result is like this:
01.02.2014
01.02.2014
01.02.2014
01.02.2014
01.02.2014
I would expect such an output:
01.11.2014
01.12.2014
01.01.2015
01.02.2015
01.03.2015
Compared to CF9:
<cfoutput>#GetLocale()#</cfoutput><br>
<cfoutput><cfset SetLocale('de_CH')></cfoutput>
<cfoutput>#GetLocale()#</cfoutput><br>
<cfset j = 5>
<cfset start_date = "10. Okt 2014">
<cfloop index = "LopingLouis" from = "1" to = "#j#">
<cfset start_date = #LSDateFormat(DateAdd('m', +1, start_date))#>
<cfset start_date = #LSDateFormat(start_date, "01. mmm yyyy")#>
<cfoutput>#start_date#</cfoutput><br>
<cfset j = j - 1>
</cfloop>
Produces this output:
01. Nov 2014
01. Dez 2014
01. Jan 2015
01. Feb 2015
01. Mrz 2015
I really don’t understand that all. Any idea what i’m doing wrong?
Win2k16
JAVA_VERSION=“11.0.3”
Tomcat 9.0.14
Lucee 5.3.8.206