Edit: It appears that date strings are no longer b...
# lucee
s
Edit: It appears that date strings are no longer being implicitly converted into dates in Lucee 6. (Lucee 6 breaking change)
e
I receive the same result on Lucee 6.0.183 as I do AFC 2023
s
I'm looking deeper into the report, where we're getting 'can't cast empty string to a number value'
So perhaps just an empty string problem
Was there a thing where empty strings in lists/arrays were previously ignored in cfloop but aren't now?
e
You are turning a string to a date. you should have a CFPARAM defaults for all values, not that its ideal.
s
Sorry, the error is actually "cannot cast [04/26/2024] string to a number value"
cfloop(from = acceptancedaterange.acceptance_start_date, to = acceptancedaterange.acceptance_end_date, index = "i", step = createTimespan(1, 0, 0, 0)) {
This is the code that used to work that doesn't anymore
Note that acceptance start_date is set to:
acceptancedaterange.acceptance_start_date = dateFormat(retstartDateTime, "mm/dd/yyyy");
So it's not implicitly converting strings to date, it seems
Sorry for the confusion.
Here's a sample of breaking code:
Copy code
<cfset fromDate = Now()> 
<cfset toDate = dateFormat(Now() + 30, "mm/dd/yyyy")> 
<cfloop from="#fromDate#" to="#toDate#" index="i" step="#CreateTimeSpan(7,0,0,0)#"> 
<cfset i = dateAdd("d", 0, i)><!--- converts number to date --->
    <cfoutput>#i.dateTimeFormat("mm/dd/yyyy")#</cfoutput> 
</cfloop>
This works on cffiddle in latest ACF
createDate has to be involved, I guess, which will involve extracting each date part
Here's a workaround:
Copy code
<cfset fromDate = Now()> 
<cfset toDate = DateFormat(Now() + 30, "mm/dd/yyyy")>
<cfset convertedToDate = createDate(Year(toDate), Month(toDate), day(toDate))> 
<cfloop from="#fromDate#" to="#convertedToDate#" index="i" step="#CreateTimeSpan(7,0,0,0)#"> 
<cfset i = dateAdd("d", 0, i)><!--- converts number to date --->
    <cfoutput>#i.dateTimeFormat("mm/dd/yyyy")#</cfoutput> 
</cfloop>
Fairly common, converting a datetime to a date in order to strip off the time string and default to 000000 so the start date includes all of the day in question
Even easier: Wrap it in
parseDateTime
A more concise working version:
Copy code
<cfset fromDate = Now()> 
<cfset toDate = DateFormat(Now() + 30, "mm/dd/yyyy")>
<cfloop from="#fromDate#" to="#parseDateTime(toDate)#" index="i" step="#CreateTimeSpan(7,0,0,0)#"> 
<cfset i = dateAdd("d", 0, i)><!--- converts number to date --->
    <cfoutput>#i.dateTimeFormat("mm/dd/yyyy")#</cfoutput> 
</cfloop>