Welcome to the Excel Forum

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed.

Please Register to Remove these Ads

Please Register to Remove these Ads



Reply
  #1  
Old 11-20-2006, 11:37 AM
OfficeBitty OfficeBitty is offline
Registered User
 
Join Date: 30 Sep 2006
Posts: 47
OfficeBitty is becoming part of the community
Ordinal Numbers in Dates

Please Register to Remove these Ads

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.
Reply With Quote
  #2  
Old 11-20-2006, 11:46 AM
starguy starguy is offline
Forum Guru
 
Join Date: 14 Mar 2006
Location: Pakistan
Posts: 1,799
starguy is becoming part of the community
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.
Reply With Quote
  #3  
Old 11-20-2006, 11:54 AM
VBA Noob's Avatar
VBA Noob VBA Noob is offline
Forum Guru
 
Join Date: 25 Apr 2006
Location: London, England
MS Office Version:xl03 & xl 07(Jan 09)
Posts: 12,315
VBA Noob has an addiction to Excel
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 !!!
Reply With Quote
  #4  
Old 11-20-2006, 12:03 PM
starguy starguy is offline
Forum Guru
 
Join Date: 14 Mar 2006
Location: Pakistan
Posts: 1,799
starguy is becoming part of the community
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)&"t h")))&" day of "&VLOOKUP(MONTH(A1),$D$1:$E$12,2,FALSE)&", "&YEAR(A1)
Reply With Quote
  #5  
Old 11-20-2006, 12:04 PM
starguy starguy is offline
Forum Guru
 
Join Date: 14 Mar 2006
Location: Pakistan
Posts: 1,799
starguy is becoming part of the community
Lightbulb

VBA Noob's formula is good if you do not want to create table.
Reply With Quote
  #6  
Old 11-20-2006, 12:06 PM
OfficeBitty OfficeBitty is offline
Registered User
 
Join Date: 30 Sep 2006
Posts: 47
OfficeBitty is becoming part of the community
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!
Reply With Quote
  #7  
Old 11-20-2006, 12:07 PM
Carim's Avatar
Carim Carim is offline
Forum Guru
 
Join Date: 07 Apr 2006
Posts: 4,001
Carim is becoming part of the community
Hi,

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

Code:
=A1&IF(AND(A1>=10,A1<=14),"th",CHOOSE(MOD(A1,10)+1,"th","st","nd","rd","th","th","th","th","th","th"))
HTH
Carim
Reply With Quote
  #8  
Old 11-20-2006, 12:15 PM
OfficeBitty OfficeBitty is offline
Registered User
 
Join Date: 30 Sep 2006
Posts: 47
OfficeBitty is becoming part of the community
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?
Reply With Quote
  #9  
Old 11-20-2006, 12:25 PM
Carim's Avatar
Carim Carim is offline
Forum Guru
 
Join Date: 07 Apr 2006
Posts: 4,001
Carim is becoming part of the community
Hi,

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

HTH
Carim
Reply With Quote
  #10  
Old 11-20-2006, 12:58 PM
VBA Noob's Avatar
VBA Noob VBA Noob is offline
Forum Guru
 
Join Date: 25 Apr 2006
Location: London, England
MS Office Version:xl03 & xl 07(Jan 09)
Posts: 12,315
VBA Noob has an addiction to Excel
Glad you got your answer

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 !!!
Reply With Quote
  #11  
Old 11-20-2006, 01:30 PM
OfficeBitty OfficeBitty is offline
Registered User
 
Join Date: 30 Sep 2006
Posts: 47
OfficeBitty is becoming part of the community
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.
Reply With Quote
  #12  
Old 11-20-2006, 01:40 PM
Carim's Avatar
Carim Carim is offline
Forum Guru
 
Join Date: 07 Apr 2006
Posts: 4,001
Carim is becoming part of the community
Hi again,

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

HTH
Carim
Reply With Quote
  #13  
Old 11-20-2006, 01:47 PM
OfficeBitty OfficeBitty is offline
Registered User
 
Join Date: 30 Sep 2006
Posts: 47
OfficeBitty is becoming part of the community
Ooh... I get it now! [sorry I am so slow] Thanks so much, Carim!
Reply With Quote
  #14  
Old 11-21-2006, 04:34 AM
Carim's Avatar
Carim Carim is offline
Forum Guru
 
Join Date: 07 Apr 2006
Posts: 4,001
Carim is becoming part of the community
Glad your problem is fixed

Thanks for the feedback

Carim
Reply With Quote


Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Forum Jump