How to Add Date Suffixes to PowerApps
🕑 Added 2024-06-19 13:32:24 +0000 UTCWant 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.
Comments
Robert Nelson
This appears to be YAML code. Will this work directly in the Power Apps Studio? Sorry not able to access an environment to test directly right now and was curious if this is the same code used in studio or used in an IDE and then imported.
Hani Sagal
Absolutely Genius!!! Thanks