I use the following code to add st, nd, rd or th to a date.
Date is the date in digits. eg: 1, 14, 26, 31 etc..
Code: Select all
f(Date)
f(d) {
Return, d . ((y := Floor(Mod(d, 10))) = 1 ? "st" : y = 2 ? "nd" : y = 3 ? "rd" : "th")
}
eg:
1st
3rd
5th
2nd
But this fails on specific dates ending 1, 2 or 3.
ie: 13 becomes 13rd, or 12 becomes 12nd
Is there anyway to do this correctly ?
Thanks