Dates - How to format date day numbers with suffix (st nd rd th)

If you need to format or get the suffix for a day number (eg 1st, 2nd, 3rd), this post describes the formula you can use.

Power Apps provides the ability to format datetime values with the help of the Text function.

The example syntax looks like this:

Text(Now(), "dd-MMM-yyyy hh:mm:ss tt zzz")

There may be a requirement to format day numbers with suffixes but unfortunately, there is no format string character that returns the day suffix.

To work around this issue, we can use the syntax beneath to return the day suffix.

$" {Text(inputDate,"dd")}{Switch(Day(inputDate),
1, "st",
21, "st",
31, "st",
2, "nd",
22, "nd",
3, "rd",
23, "rd",
)} {Text(inputDate,"mmm yyy")}"

This formula extracts the parts of the string. It calls the Switch function on the day number and conditionally returns the suffix for the day number.

Here's a screenshot that shows the result.

How to superscript day suffixes

It's common to format the day suffixes with superscript characters. We can accomplish this by using the Unicode superscript characters (copying and pasting the code block beneath will work).

$" {Text(inputDate,"dd")}{Switch(Day(inputDate),
1, "ˢᵗ",
21, "ˢᵗ",
31, "ˢᵗ",
2, "ⁿᵈ",
22, "ⁿᵈ",
3, "ʳᵈ",
23, "ʳᵈ",
)} {Text(inputDate,"mmm yyy")}"

As shown in the screenshot beneath, the 'th' suffix is now formatted with superscript characters.



This post described the formula to display the suffix for a day number. It also demonstrated how to display the suffix with superscript characters.