Thanks diogofgm, you're right it did not end up being as complex as I thought it would, but I think you're missing some of the conditions, especially "everything else gets th"
I changed it to:
eval ordinal = foo + case((foo>=10 AND foo<=20),"th",foo%10 = 1,"st",foo%10 = 2,"nd",foo%10 = 3,"rd",true(),"th")
The true() will match everything else as yet undefined by the case and give it "th"
However this still doesn't handle foo values ending 11,12,or 13 like 1,112, which will get "1112nd" with the above code.
... View more