Date Tags (1st, 2nd etc)

If you keen to have the suffix in your date - here it is;

$#DdL#==01?1st:$$#DdL#==02?2nd:$$#DdL#==03?3rd:$$#DdL#==04?4th:$$#DdL#==05?5th:$$#DdL#==06?6th:$$#DdL#==07?7th:$$#DdL#==08?8th:$$#DdL#==09?9th:$$#DdL#==10?10th:$$#DdL#==11?11th:$$#DdL#==12?12th:$$#DdL#==13?13th:$$#DdL#==14?14th:$$#DdL#==15?15th:$$#DdL#==16?16th:$$#DdL#==17?17th:$$#DdL#==18?18th:$$#DdL#==19?19th:$$#DdL#==20?20th:$$#DdL#==21?21st:$$#DdL#==22?22nd:$$#DdL#==23?23rd:$$#DdL#==24?24th:$$#DdL#==25?25th:$$#DdL#==26?26th:$$#DdL#==27?27th:$$#DdL#==28?28th:$$#DdL#==29?29th:$$#DdL#==30?30th:$$#DdL#==31?31st:$

5 Likes

Welcome @bradleyturney73 . Some one who comes bearing Gifts . Nice . You will fit in well here .

3 Likes

Welcome to the forum bradleyturney73.

1 Like

Welcome @bradleyturney73. You got me thinking there, could it be done in a shorter form?
Of course, yours is easier to read and absolutely correct.

I do not particularly like nested conditions, may not always work. But, anyway, for those that like a little math, here a shorter version:

$(#Dd#%10)=1&&#Dd#!=11?#Dd#st:$$(#Dd#%10)=2&&#Dd#!=12?#Dd#nd:$$(#Dd#%10)=3&&#Dd#!=13?#Dd#rd:$$#Dd#>3&&#Dd#<21?#Dd#th:$$#Dd#>23&&#Dd#<31?#Dd#th:$

Taking it apart, what it does is:

$(#Dd#%10)=1&&#Dd#!=11?#Dd#st:
add “st” to the day if that last digit of the day is 1, unless it is the 11th

$$(#Dd#%10)=2&&#Dd#!=12?#Dd#nd:
add “nd” to the day, if the last digit is 2, unless it is the 12th

$$(#Dd#%10)=3&&#Dd#!=13?#Dd#rd:
add “rd” to the day, unless it is the 13th

$$#Dd#>3&&#Dd#<21?#Dd#th:
is the day between the 4th and 20th, add “th”

$$#Dd#>23&&#Dd#<31?#Dd#th:$
is the day between the 24th and the 30th, add “th”

5 Likes

Awesome.

3 Likes

Jesus!!

You crazy kids… :heart_eyes: :heart_eyes: :+1:

2 Likes