Highlighted

Illegal Number Range Exception

New Here ,
Mar 16, 2020

Copy link to clipboard

Copied

 
 

Calendar.PNG

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.

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 your user interface, have you considered using a javascript-based date, time or daterange widget?  We've been using Date Range Picker and it has simplified data entry like this, but I only recommend it if you require start & end date/time values. If your date and/or time entry fields are optional, you may want to use something like Pikaday or TimePicker. (There are other client-side libraries available; these are just what we're currently using in production.)

 

Regarding number ranges, use CFLOOP to go from="00" to="23" for the hour and from="00" to="59" for the minute.

TOPICS
Advanced techniques

Views

684

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Illegal Number Range Exception

New Here ,
Mar 16, 2020

Copy link to clipboard

Copied

 
 

Calendar.PNG

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.

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 your user interface, have you considered using a javascript-based date, time or daterange widget?  We've been using Date Range Picker and it has simplified data entry like this, but I only recommend it if you require start & end date/time values. If your date and/or time entry fields are optional, you may want to use something like Pikaday or TimePicker. (There are other client-side libraries available; these are just what we're currently using in production.)

 

Regarding number ranges, use CFLOOP to go from="00" to="23" for the hour and from="00" to="59" for the minute.

TOPICS
Advanced techniques

Views

685

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Mar 16, 2020 0
Adobe Community Professional ,
Mar 17, 2020

Copy link to clipboard

Copied

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. 

/Charlie (server troubleshooter, carehart.org)

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Mar 17, 2020 0
Engaged ,
Mar 17, 2020

Copy link to clipboard

Copied

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 your user interface, have you considered using a javascript-based date, time or daterange widget?  We've been using Date Range Picker and it has simplified data entry like this, but I only recommend it if you require start & end date/time values. If your date and/or time entry fields are optional, you may want to use something like Pikaday or TimePicker. (There are other client-side libraries available; these are just what we're currently using in production.)

 

Regarding number ranges, use CFLOOP to go from="00" to="23" for the hour and from="00" to="59" for the minute.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Mar 17, 2020 0
Adobe Community Professional ,
Apr 10, 2020

Copy link to clipboard

Copied

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.

/Charlie (server troubleshooter, carehart.org)

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 10, 2020 0