This reminds me of one of my favorite programming glitches.

http://www.google.com/search?q=11st
http://www.google.com/search?q=12nd
http://www.google.com/search?q=13rd

Seriously, though, I made a little number namer a while ago, and it's 
all tags and not cfscript, but here it is for ya.

<!---
3/4/2003, ns
returns numbers followed by a discriptive string. 1st, 2nd, 3rd, 245th
--->
<cffunction name="NumberName" output="no" returntype="string">
        <cfargument name="num" required="Yes" type="numeric">
        <cfset var returnName = "">

        <cfswitch expression="#Right(NumberFormat(arguments.num,"09"),2)#">
                <cfcase value="11,12,13">
                        <cfset returnName = "th">
                </cfcase>
                <cfdefaultcase>
                        <cfswitch expression="#Right(arguments.num,1)#">
                                <cfcase value="1">
                                        <cfset returnName = "st">
                                </cfcase>
                                <cfcase value="2">
                                        <cfset returnName = "nd">
                                </cfcase>
                                <cfcase value="3">
                                        <cfset returnName = "rd">
                                </cfcase>
                                <cfcase value="4,5,6,7,8,9,0">
                                        <cfset returnName = "th">
                                </cfcase>
                        </cfswitch>
                </cfdefaultcase>
        </cfswitch>
        
        <cfreturn num & returnName>
</cffunction>


Rick Root wrote:
> Does anyone have a function that takes numbers and converts them to 1st, 
> 2nd, 3rd, ... 15th, .. 21st, etc?
> 
>   - Rick
> 
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Special thanks to the CF Community Suite Silver Sponsor - RUWebby
http://www.ruwebby.com

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:188558
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to