+ Reply to Thread
Results 1 to 6 of 6

Ordinal Dates and numbers (st,nd,rd,th)

  1. #1
    Valued Forum Contributor squiggler47's Avatar
    Join Date
    02-17-2009
    Location
    Littleborough, UK
    MS-Off Ver
    Excel 3.0 to 2007+2010! (couldnt get 2.1 working)
    Posts
    1,013

    Ordinal Dates and numbers (st,nd,rd,th)

    I was just looking at a formula for ordinal dates, which contained 7 references to cell A1, I came up with a better and more flexible way :-

    =SUBSTITUTE(TEXT($A$1,"mmmm dzz, yyyy"),"zz",MID("thstndrdthththththth",2*MOD(DAY($A$1),10)*(INT(DAY($A$1)/10)<>1)+1,2))

    for April 1st,2010

    =SUBSTITUTE(TEXT($A$1,"dzz of mmmm yyyy"),"zz",MID("thstndrdthththththth",2*MOD(DAY($A$1),10)*(INT(DAY($A$1)/10)<>1)+1,2))

    for 1st April 2010

    =SUBSTITUTE(TEXT($A$1,"dddd t\h\e dzz of mmmm yyyy"),"zz",MID("thstndrdthththththth",2*MOD(DAY($A$1),10)*(INT(DAY($A$1)/10)<>1)+1,2))

    for Thursday the 1st of April 2010

    =SUBSTITUTE(TEXT($A$1,"dddd mmmm dzz, yyyy"),"zz",MID("thstndrdthththththth",2*MOD(DAY($A$1),10)*(INT(DAY($A$1)/10)<>1)+1,2))

    for Thursday April 1st, 2010

    if you just wish to use it for any number to ordinal

    =A1&MID("thstndrdthththththth",2*MOD(A1,10)*(INT(MOD(A1,100)/10)<>1)+1,2)
    Regards
    Darren

    Update 12-Nov-2010 Still job hunting!

    If you are happy with the results, please add to our reputation by clicking the blue scales icon in the blue bar of the post.

    Learn something new each day, Embrace change do not fear it, evolve and do not become extinct!


  2. #2
    Valued Forum Contributor squiggler47's Avatar
    Join Date
    02-17-2009
    Location
    Littleborough, UK
    MS-Off Ver
    Excel 3.0 to 2007+2010! (couldnt get 2.1 working)
    Posts
    1,013

    Re: Ordinal Dates and numbers (st,nd,rd,th)

    Rather annoyingly I managed to decrease the references to the original cell again, every other version I have found on the web had 4 references to add an ordinal I have got that down to 1 which makes it easier to maintain!

    =a1&MID(SUBSTITUTE(REPT("thstndrdthththththth",10),"stndrd","ththth",2),MOD(a1,100)*2+1,2)

  3. #3
    Registered User
    Join Date
    05-24-2014
    Posts
    2

    Re: Ordinal Dates and numbers (st,nd,rd,th)

    Thanks for your post, it has really helped me

  4. #4
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Ordinal Dates and numbers (st,nd,rd,th)

    Here's an even simpler version for numbers (not dates):

    =A1&MID("thstndrdth",MIN(9,2*RIGHT(A1)*(MOD(A1-11,100)>2)+1),2)

    Can be incorporated into date processing, too:

    =DAY(A1)&MID("thstndrdth",MIN(9,2*RIGHT(DAY(A1))*(MOD(DAY(A1)-11,100)>2)+1),2)&TEXT(A1," MMMM, YYYY")

    =TEXT(A1,"DDDD, ")&DAY(A1)&MID("thstndrdth",MIN(9,2*RIGHT(DAY(A1))*(MOD(DAY(A1)-11,100)>2)+1),2)&TEXT(A1," MMMM, YYYY")

    =TEXT(A1,"DDDD, ")&DAY(A1)&MID("thstndrdth",MIN(9,2*RIGHT(DAY(A1))*(MOD(DAY(A1)-11,100)>2)+1),2)&TEXT(A1," of MMMM YYYY")

    =TEXT(A1,"DDDD")&" the "&DAY(A1)&MID("thstndrdth",MIN(9,2*RIGHT(DAY(A1))*(MOD(DAY(A1)-11,100)>2)+1),2)&TEXT(A1," of MMMM, YYYY")
    Cheers,
    Paul Edstein
    [Fmr MS MVP - Word]

  5. #5
    Registered User
    Join Date
    05-24-2014
    Posts
    2

    Ordinal Dates and numbers (st,nd,rd,th)

    Tested and works marvelous, thanks again

  6. #6
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Ordinal Dates and numbers (st,nd,rd,th)

    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1