You need to sign in to do that
Don't have an account?
Jim Boudreaux
Ordinal Conversion Method
Hey, check me out!
public string getOrdinal(integer i){ string num = string.valueof(i); string suffix = 'th'; string ordinal = ''; i = integer.valueof(num.right(2)); if(10 < i && i < 14) { ordinal = num + suffix; }else{ string onesDigit = num.right(1); if(onesDigit == '1'){ suffix = 'st'; }else if(onesDigit == '2'){ suffix = 'nd'; }else if(onesDigit == '3'){ suffix = 'rd'; } ordinal = num+suffix; } return ordinal; }
:D
Hey Jim,
Apex and Visualforce for fun and profit. Rock on:-) I think you left out the 'ty' part for 20, 30, 40 etc. oh - never mind - 20th, 30th since 'th' is your default.
Best,
Ram