Default schedule for Steve Employee is Monday - Friday from 6:00 PM to 2:00 AM.
startdate = 10/14/2018
starttime = 6:00 PM
endtime = 2:00 AM (the next day)
When I generate the schedule in ColdFusion, it loops through each date where DayofWeek is in (2,3,4,5,6 which is Monday - Friday) but it doesn't know the end time is not the same date as the start time because it passed midnight during his shift.
How can I loop through the times to find the date when the time goes past midnight?
His shift is 8 hours long, but
#DateDiff('n',starttime,endtime)#
is returning -16 hours,
so I can't even tell how many hours this time range is, or I could do a loop from the starting-date-time and add 8 hours.
This loop doesn't even run.
<cfset startTime = "#startdate# #starttime#">
<cfset endTime = #endtime#>
<cfloop from="#startTime#" to="#endTime#" index="i" step="#CreateTimeSpan(0,1,0,0)#">
<cfoutput>#DateTimeFormat(i)#</cfoutput>
</cfloop>
Desired result:
10/14/2018 6:00 PM
10/14/2018 7:00 PM
10/14/2018 8:00 PM
10/14/2018 9:00 PM
10/14/2018 10:00 PM
10/14/2018 11:00 PM
10/15/2018 12:00 AM
10/15/2018 1:00 AM
Thanks for your ideas.