This should do it... I wrote it for a list of "Top 10 Scores" in a game but
changed it a little to work with larger numbers. Hope it helps
<cfscript>
function nth(num)
{
if (right(num, 1) is "1" and right(num, 2) NEQ "11")
{
num = num & "st";
}
else if (right(num, 1) is "2" and right(num, 2) NEQ "12")
{
num = num & "nd";
}
else if (right(num, 1) is "3" and right(num, 2) NEQ "13")
{
num = num & "rd";
}
else
{
num = num & "th";
}
return num;
}
</cfscript>
-----Original Message-----
From: Rick Root [mailto:[EMAIL PROTECTED]
Sent: Wednesday, December 22, 2004 12:36 PM
To: CF-Talk
Subject: 1st, 2nd, 3rd, 4th
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 - CFDynamics
http://www.cfdynamics.com
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:188664
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=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54