Want to add date suffixes in PowerApps effortlessly?
It’s simpler than you think!
It has always bugged me that there isn’t a straightforward way to automatically assign date suffixes like "th" or "st" in PowerApps. With this simple code, you can achieve that effortlessly.
The trick is to use the With() function to get all the individual parts of the date you want to display, whether it's "Day of The Week," "Day," "Month," or "Year." Then, using the Switch statement, check the day and automatically assign a suffix. Since there are only 31 days in a month, only seven days will have a custom suffix, and the rest will use the default "th." Once that is done, combine all the individual parts using a formatted string.
In my case, I’m converting "2024-06-23" to "23rd Jun." I prefer this approach because it involves just a few lines of code and is customizable for multiple scenarios.
Robert Nelson
2024-10-02 11:56:42 +0000 UTCHani Sagal
2024-06-20 09:28:00 +0000 UTC