+ Reply to Thread
Results 1 to 14 of 14

Ordinal Numbers in Dates

  1. #1
    Registered User
    Join Date
    09-30-2006
    Posts
    47

    Ordinal Numbers in Dates

    Hi everyone,

    I've been trying to figure out ordinal numbers in Excel, and I found information on how to turn a cardinal number into an ordinal number... but now I need to figure out if there is a way to have them take the number from a date, and return it in a date format... Like this:

    A1 = 11/25/06
    B1 = 25th day of November, 2006

    I would appreciate any advice/assistance.

  2. #2
    Forum Contributor
    Join Date
    03-14-2006
    Location
    Pakistan
    Posts
    1,791

    Lightbulb

    Quote Originally Posted by OfficeBitty
    Hi everyone,

    I've been trying to figure out ordinal numbers in Excel, and I found information on how to turn a cardinal number into an ordinal number... but now I need to figure out if there is a way to have them take the number from a date, and return it in a date format... Like this:

    A1 = 11/25/06
    B1 = 25th day of November, 2006

    I would appreciate any advice/assistance.
    it would be easy if you maintain a table like this

    1 January
    2 February
    3 March
    and so on...

    then use this formula (I suppose that date is entered in cell A1 and table like above for 12 months is in the range of D1:E12)

    =DAY(A1)&" "&"day of "&VLOOKUP(MONTH(A1),$D$1:$E$12,2,FALSE)&", "&YEAR(A1)

    you can change ranges according to your data.

    Regards.

  3. #3
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Hi,

    or

    =DAY(A1)&IF(INT(MOD(DAY(A1),100)/10)=1, "th", IF(MOD(DAY(A1),10)=1, "st", IF(MOD(DAY(A1),10)=2,"nd", IF(MOD(DAY(A1),10)=3, "rd","th"))))& " day of " & TEXT(A1,"mmmm yyyy")

    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  4. #4
    Forum Contributor
    Join Date
    03-14-2006
    Location
    Pakistan
    Posts
    1,791

    Lightbulb

    for having "rd", "nd" and "th" at the end of day number.
    try this

    IF(RIGHT(DAY(A1),1)*1=1,"1st",IF(RIGHT(DAY(A1),1)*1=2,"2nd",IF(RIGHT(DAY(A1),1)*1=3,"3rd",DAY(A1)&"th")))&" day of "&VLOOKUP(MONTH(A1),$D$1:$E$12,2,FALSE)&", "&YEAR(A1)

  5. #5
    Forum Contributor
    Join Date
    03-14-2006
    Location
    Pakistan
    Posts
    1,791

    Lightbulb

    VBA Noob's formula is good if you do not want to create table.

  6. #6
    Registered User
    Join Date
    09-30-2006
    Posts
    47
    Thank you both for the advice, StarGuy & VBA Noob!

    I was able to use the information you two provided to get the result that I was trying for!

  7. #7
    Forum Expert Carim's Avatar
    Join Date
    04-07-2006
    Posts
    4,070
    Hi,

    Along side VBA Noob's formula, you can try this shorter one ...(no table)

    Please Login or Register  to view this content.
    HTH
    Carim

  8. #8
    Registered User
    Join Date
    09-30-2006
    Posts
    47
    Thank you for your advice also, Carim!

    I tried your formula (the no table part is always great!), but I think I might have done something wrong as the cell I put the formula into gets a thick border around it, and displays a long number... what could be causing this?

  9. #9
    Forum Expert Carim's Avatar
    Join Date
    04-07-2006
    Posts
    4,070
    Hi,

    It is related to your own cell settings ... just format cell as you wish ...

    HTH
    Carim

  10. #10
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Glad you got your answer

    VBA Noob

  11. #11
    Registered User
    Join Date
    09-30-2006
    Posts
    47
    I'm sorry Carim, I still can't seem to get your formula to work for me... I keep fiddling with my cell format, but can't get the result to change... I'll keep trying it, but in the meantime, your advice did get me thinking about using a shorter formula... I decided to use a function for making the ordinal number, and that way I could use parts of StarGuy's formula and also parts of VBA Noob's formula, and make it short like yours to get the same result.

    =OrdinalNumber(DAY(A1))&" "&"day of "&TEXT(A1,"mmmm yyyy")

    If you have any idea how I could be getting your formula wrong, Carim, please advise me a little further on that one. I've reformatted the cell and other cells and pasted your formula in different cells, but I can't seem to get it right.

  12. #12
    Forum Expert Carim's Avatar
    Join Date
    04-07-2006
    Posts
    4,070
    Hi again,

    I forgot to mention that within formula A1 has to be replaced by
    day(yourdate) ...

    HTH
    Carim

  13. #13
    Registered User
    Join Date
    09-30-2006
    Posts
    47
    Ooh... I get it now! [sorry I am so slow] Thanks so much, Carim!

  14. #14
    Forum Expert Carim's Avatar
    Join Date
    04-07-2006
    Posts
    4,070
    Glad your problem is fixed

    Thanks for the feedback

    Carim

+ 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