Number Suffixes in AMPScript

Suppose you want to output a day of the month with a proper suffix (e.g. 1st, 13th). There aren’t any formatting functions in AMPScript to do it, but you can do it with a set of if-statements:

Output

1st
2nd
3rd
4th
5th
6th
7th
8th
9th
10th
11th
12th
13th
14th
15th
16th
17th
18th
19th
20th
21st
22nd
23rd
24th
25th
26th
27th
28th
29th
30th
31st

Once you’re satisfied that it works, you can simply remove the for-loop and un-comment the set @day = Format(Now(),"dd")) line

Reference

2
Leave a Reply

avatar
1 Comment threads
1 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
2 Comment authors
Adam SpriggsDaniel Recent comment authors
  Subscribe  
newest oldest most voted
Notify of
Daniel
Guest

Hey Adam, I may be wrong, but it looks like line 7 of your code example has an extra parenthesis, as well as the last comment in the blog post.