Last active
September 19, 2018 21:48
-
-
Save wvpv/478db63dd8b1b0d22b47a4222152226f to your computer and use it in GitHub Desktop.
Number Suffixes in AMPScript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%%[ | |
var @day, @suffix | |
for @day = 1 to 31 do | |
/* set @day = Format(Now(),"dd") */ | |
/* adapted from http://stackoverflow.com/a/13627586/812377 */ | |
if mod(@day,10) == 1 and mod(@day,100) != 11 then | |
set @suffix = "st" | |
elseif mod(@day,10) == 2 and mod(@day,100) != 12 then | |
set @suffix = "nd" | |
elseif mod(@day,10) == 3 and mod(@day,100) != 13 then | |
set @suffix = "rd" | |
else | |
set @suffix = "th" | |
endif | |
outputline(concat("<br>",@day,@suffix)) | |
next @i | |
]%% |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yes! Updated. Thank you.