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:

See the gist on github.

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

Share
Published by
Adam Spriggs @wvpv

Recent Posts

3D Printed Mechanical Counter

https://youtu.be/pBoHq3AG8rw Amazing mechanical counter by Florian Hu. Here's the 3D model. More from Florian Hu: Projects | Portfolio

1 month ago

How can leaders learn empathy?

https://youtu.be/8Yrmopm5Npc [...] maximizing shareholder value [...] where we prioritize the wants, needs, and desires of an external constituency over our…

1 month ago

143 Robin Lopez Hook Shots

https://youtu.be/D-QaDLfogNM Check out 143 hook shots by Robin Lopez from the 2018-19 season.

2 months ago

How Pencils are Made

https://youtu.be/aPb-slJH9Vs

2 months ago

Just read the documentation

They said, "just read the official documentation"...

3 months ago