Guide to add suffix st,nd,rd,th to the number

Hi,

I needed a long date with suffix st,nd,rd,th to the date. Could not find much of an option on searching. So came up with a simple logic to have the suffix added. Hope it helps others who need it. Code is self explanatory.

If there is a better way, let me know.

Cheers,
Mohan

Nice guide, but I think there is an exception: 11 has a remainder of 1 when you divide it by 10, but its ordinal is eleventh.

EDIT: Think of twelth and thirteenth as well…

1 Like

Good Point. Thanks for pointing that out. Here is the updated logic below