# 19.0 Must Be Within Range: ( 1 : 12 )

Posted July 30, 2007 at 5:18 PM by Ben Nadel

Tags: ColdFusion

I was just helping someone debug a strange ColdFusion error:

19.0 Must Be Within Range: ( 1 : 12 ). ColdFusion cannot determine the line of the template that caused this error. This is often caused by an error in the exception handling subsystem.

Because ColdFusion wasn't giving us any template or line numbers, we basically had to start commenting out code and putting it back in until we narrowed down the template and the line. And, seeing as I was not working on the project, this was particularly necessary (as I was not familiar with the code at all - just called over for the error). Finally, we narrowed it down to the ColdFusion method, MonthAsString(). This takes a month index and returns the name of the month. Therefore, running:

• #MonthAsString( 1 )#

... gives us:

January

The values, obviously, can only be 1 - 12, as there are only 12 months in the year. As it turns out, there was some weird math algorithm that was passing a variable of the value 19 to the MonthAsString() function; hence the whole out of range error.

Good to know if I ever see this error again.

### Looking For a New Job?

25% of job board revenue is donated to Kiva. Loans that change lives - Find out more »

Jul 31, 2007 at 12:49 AM // reply »

When I was a kid I ran across a few page insert in a day planner that had a system to calculate the day of week (Monday, Thursday, etc.) of any date between around 1500 and 2100. Years later I realized it was based on an algorithm that works for our current calendar system(Gregorian).

I suspect the 19 is a remnant of the formula. The days of week fall on a fairly predictable basis for hundreds of years based on a relatively easy formula.

Aug 3, 2007 at 12:41 PM // reply »

Cool

Nov 3, 2009 at 2:43 PM // reply »

I recently had a similar ColdFusion error with no line number information to help:
11.0 must be within range: ( 1 : 7 )

The date in my Form variable was "11/11/2009" and I was doing this:

After finding this blog entry, I quickly discovered I was out of the range for days in a week and fixed the inner function call:

Nov 3, 2009 at 2:57 PM // reply »

@Troy,

Yeah, that'll get you ever time :) Good catch.

Feb 11, 2010 at 10:57 AM // reply »

thanks for sharing this. saved me a lotta time.

Feb 11, 2010 at 10:59 AM // reply »

@Ash,

No problem my man.

Aug 31, 2010 at 2:17 PM // reply »

Just hit this one myself, but wasn't having any luck with it.

<cfswitch expression="#dayofweek(now())#">
<cfcase value="1,7">Weekend</cfcase>
<cfcase value="2">Monday</cfcase>
<cfdefaultcase>Other Day</cfdefaultcase>
</cfswitch>

finally realized... it was because I was outputting #DayOfWeekAsString(NOW())# to get the name of the "Other Day" in some text... As with Troy above, adding dayofweek() into the mix fixed it.

Really strange and unexpected behavior for me.. usually coldfusion is so friendly that it just does that sort of conversion behind the scenes for you.

Sep 3, 2010 at 10:42 PM // reply »

@JC,

Yeah, especially with dates - you can throw just about anything at ColdFusion and, chances are, it can convert it to a date :)

Comment Etiquette: Please do not post spam. Please keep the comments on-topic. Please do not post unrelated questions or large chunks of code. And, above all, please be nice to each other - we're trying to have a good conversation here.

 Author Name: Author Email: Author Website: Comment: Supported HTML tags for formatting: bold   italic   code Remember my information Subscribe to comments Send me a copy of this comment
InVision App - Prototyping Made Beautiful With Prototyping Tools Recent Blog Comments
Mar 10, 2014 at 8:24 PM
Nested Views, Routing, And Deep Linking With AngularJS
@Steven, the action property is not something from AngularJS but rather part of the concept that Ben is describing in his blogpost here. it is a custom added property, which is read by the requestCo ... read »
Mar 10, 2014 at 2:03 PM
Nested Views, Routing, And Deep Linking With AngularJS
Where is the angular documentation for 'action:' it is not here: http://docs.angularjs.org/api/ngRoute/provider/ \$routeProvider Thanks. ... read »
Mar 10, 2014 at 12:06 PM
Using Track-By With ngRepeat In AngularJS 1.2
I was hoping that this will work with pagination using ng-repeat. My use case scenario is that I have an images object. images[0] = [im1,im2,im3] // First Page images[1] = [im4, im5, im6] // Second ... read »
Mar 9, 2014 at 6:11 PM
For Better Security Use HtmlEditFormat() In Conjunction With JSStringFormat() In ColdFusion
It looks like htmleditformat() will be deprecated in CF 11 https://wikidocs.adobe.com/wiki/display/coldfusionen/New +in+ColdFusion ... read »
Mar 9, 2014 at 10:55 AM
\$.stop() vs. \$.finish() In jQuery Animations
Nice feature! Thanks for sharing. :) Good for when you are making a 100% AJAX controlled site. ... read »
Mar 9, 2014 at 12:26 AM
Experimenting With Multiple Class Inheritance In Javascript
@bigboomshakala, Hi, I am want present so solution for multiple prototypical inheritance, but some restrictions. Please follow the link: http://arto8.site11.com/ArtoJS/multi-inheritance-prototype.ph ... read »
Mar 8, 2014 at 5:21 PM