Create a gist now

Instantly share code, notes, and snippets.

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
]%%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment