Forum Discussion
Steve K
Sep 13, 2023Brass Contributor
Convert numbers to ordinal numbers (1st, 2nd, 3rd, etc.)
I suggested to a client they should stop entering ordinals (text values) and use numbers instead to facilitate sorting and calculations. I wish Excel had a number format for this, but it doesn't. I c...
Patrick2788
Sep 13, 2023Silver Contributor
Steve K
Playing with a lambda in Python for Excel:
ordinal = lambda n: "%d%s" % (n,"tsnrhtdd"[(n//10%10!=1)*(n%10<4)*n%10::4])
for i in range(1,100):
print(ordinal(i))