Skip to content

Instantly share code, notes, and snippets.

@wvpv
Last active September 19, 2018 21:48
Show Gist options
  • Save wvpv/478db63dd8b1b0d22b47a4222152226f to your computer and use it in GitHub Desktop.
Save wvpv/478db63dd8b1b0d22b47a4222152226f to your computer and use it in GitHub Desktop.
Number Suffixes in AMPScript
%%[
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
]%%
@wvpv
Copy link
Author

wvpv commented Sep 19, 2018

Yes! Updated. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment