+ Reply to Thread
Results 1 to 2 of 2

Thread: 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,006

    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,006

    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)
    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!


+ 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.2.0