Skip to main content
Participant
August 12, 2008
Answered

Adding "th", "nd", "rd" or "st" to dates

  • August 12, 2008
  • 3 replies
  • 1618 views
Hi All,

Has anyone come across a date formatting function which can add the appropriate "th", "nd", "rd" or "st" to a date?
I've done a fair bit of googling and haven't come across anything which takes into account that not all numbers ending in 1 should have an "st" appended to them (e.g. 11) or for that matter not all numbers ending in 2 should have a "nd" appended to them (e.g. 12) and so on.

Kylie
    This topic has been closed for replies.
    Correct answer Newsgroup_User
    yep, seen one over at cflib.org.
    can't recall what the function name is, though, sorry...

    well, a quick check has foundit. here it is:
    http://www.cflib.org/udf/GetOrdinal

    Azadi Saryev
    Sabai-dee.com
    http://www.sabai-dee.com/

    3 replies

    Participant
    August 12, 2008
    Thank you for the direction to cflib.org, I'm not really an experienced CF programmer, rather a designer looking after a CF site, so I wouldn't try to write one.

    You should really read people's messages properly before you try to give them shtick though...I said not all numbers ending in one should have an "st" appended to them and my example of this exception was the number 11. Although I'm not proficient with CF, I am proficient with the English language. Obviously 11 and 12 are both suffixed with “th”, giving you 11th and 12th.

    Regards,
    Kylie
    Inspiring
    August 12, 2008
    It would be pretty easy to write one. cfib.org is a repository of udf's if your searching to date has not taken you there.

    By the way, where I live, it's the 11th and 12th, not the 11st and 12nd. But I guess it depends on your target audience.
    Newsgroup_UserCorrect answer
    Inspiring
    August 12, 2008
    yep, seen one over at cflib.org.
    can't recall what the function name is, though, sorry...

    well, a quick check has foundit. here it is:
    http://www.cflib.org/udf/GetOrdinal

    Azadi Saryev
    Sabai-dee.com
    http://www.sabai-dee.com/
    Participant
    August 12, 2008
    Brilliant! This worked like a charm. Thank you soooooo much.

    Kylie