-Lisa- Posted March 28, 2016 Share Posted March 28, 2016 Can the FormatDate function be used to include ordinals (i.e. "th", "st", etc.)? Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted March 28, 2016 Share Posted March 28, 2016 (edited) No, but if you search the web for "JavaScript ordinals", you'll find lots of functions to do that, such as this one: function getOrdinal(n) { var s = ["th","st","nd","rd"]; var v = n % 100; return s[(v-20)%10] || s[v] || s[0]; } You can use it in a rule like this: var theDate = Today(); var dayOfMonth = theDate.getDate(); var dayWithOrdinal = getOrdinal(dayOfMonth); return FormatDate(theDate, "EE, MMM d") + dayWithOrdinal + FormatDate(theDate, ", yyyy"); Adding this functionality to FormatDate wouldn't be a bad enhancement idea for FusionPro, although such ordinals are obviously specific to English, and not all of our users, and certainly not all output files, are English-based. Different languages do ordinals much differently: https://en.wikipedia.org/wiki/Ordinal_indicator Edited March 28, 2016 by Dan Korn Added note about ordinals in other languages. Quote Link to comment Share on other sites More sharing options...
-Lisa- Posted March 28, 2016 Author Share Posted March 28, 2016 AWESOME! Thank you, Dan! This was super helpful!!!! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.