The minute drop down works fine in CF9, but my development server has 2018 on it because we are looking at upgrading. However, I am getting a runtime error on the minute dropdown in 2018. My problem is, I can't figure out how to set a number range for the minutes.
<cfset fullStartDate=CreateDateTime(DateFormat(form.STARTDATE,'yyyy'), DateFormat(form.STARTDATE,'mm'), DateFormat(form.STARTDATE,'dd'),Form.STARTHOUR, Form.STARTMINUTE,0)>
This is the code that works just fine in CF9.
Please make a standalone example that demonstrates the problem. And really, for now leave off the drop down and just focus on sharing the values in the form fields, and show the output of those functions. Assuming you feed that into the drop down, that may be your problem.
And if you don't want to create test code on your own machine, you can use a site like Cffiddle.org, where you can run it live and even save a link that you can share and we can see/test the code.
Then again, we need to know your form field values, and if you feel you can't have your code dumping such debug output, you can just log it with cflog, assuming you can access the cf logs folder. There are still other approaches, but let's see where all this gets you.
Are you sure that all of the returned form values are able to generate a valid date?
Regarding date consruction, this is simplier code... but you'd need to ensure that form.STARTDATE is a valid date to begin with:
<cfset fullStartDate = CreateDateTime(Year(form.STARTDATE), Month(form.STARTDATE), Day(form.STARTDATE'), VAL(Form.STARTHOUR), val(Form.STARTMINUTE), 0)>
or you could try something like this.
<cfparam name="form.STARTDATE" default=""> <cfparam name="form.STARTHOUR" default="00" type="numeric"> <cfparam name="form.STARTMINUTE" default="00" type="numeric"> <cfset fullStartDate = ""> <cfif isDate(form.STARTDATE)> <cftry> <cfset fullStartDate = ParseDateTime("#form.STARTDATE# #NumberFormat(VAL(Form.STARTHOUR),'00')#:#NumberFormat(VAL(Form.STARTMINUTE),'00')#:00")> <cfcatch> <cfthrow message="Invalid date/time: #form.STARTDATE# #NumberFormat(VAL(Form.STARTHOUR),'00')#:#NumberFormat(VAL(Form.STARTMINUTE),'00')#:00"> </cfcatch> </cftry> </cfif>
Regarding number ranges, use CFLOOP to go from="00" to="23" for the hour and from="00" to="59" for the minute.
I see someone marked Jamo's answer as "correct", but I'm not seeing anything more to explain that. Can whoever did that, elaborate? If srouse72, did it end up being the bad form data he suggested could be the problem? or that it was not a date after all? or did the alternative date picker work better? It would just help to have context.