• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Illegal Number Range Exception

Explorer ,
Mar 16, 2020 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.

TOPICS
Advanced techniques

Views

890

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
community guidelines

correct answers 1 Correct answer

Enthusiast , Mar 17, 2020 Mar 17, 2020

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" ty
...

Votes

Translate

Translate
Community Expert ,
Mar 17, 2020 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 (troubleshooter, carehart.org)

Votes

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
community guidelines
Enthusiast ,
Mar 17, 2020 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.

Votes

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
community guidelines
Community Expert ,
Apr 10, 2020 Apr 10, 2020

Copy link to clipboard

Copied

LATEST

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 (troubleshooter, carehart.org)

Votes

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
community guidelines
Resources
Documentation