A Microsoft Office (Excel, Word) forum. OfficeFrustration

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. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » Worksheet Functions
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Date abbreviations / extensions



 
 
Thread Tools Display Modes
  #1  
Old March 4th, 2010, 04:49 PM posted to microsoft.public.excel.worksheet.functions
Keyrookie[_55_]
external usenet poster
 
Posts: 1
Default Date abbreviations / extensions


Is there a way to have dates show with extensions like, "st", "nd",
"rd", "th"
when using the NOW() formula? In other words, when the date changes
from the 1st to the 2nd will Excel display the extensions? Or, is
there a way automatically to spell out the dates, (First, Third,
Sixteenth, etc.) using the NOW() or some other formula?

Thanks,
K




--
Keyrookie
  #2  
Old March 4th, 2010, 08:22 PM posted to microsoft.public.excel.worksheet.functions
Gord Dibben
external usenet poster
 
Posts: 20,252
Default Date abbreviations / extensions

One method using a UDF

Function OrdinalNumber(ByVal Num As Long) As String
Dim N As Long
Const cSfx = "stndrdthththththth"
N = Num Mod 100
If ((Abs(N) = 10) And (Abs(N) = 19)) _
Or ((Abs(N) Mod 10) = 0) Then
OrdinalNumber = Format(Num) & "th"
Else
OrdinalNumber = Format(Num) & Mid(cSfx, _
((Abs(N) Mod 10) * 2) - 1, 2)
End If
End Function

In a cell enter

=TEXT(NOW(),"mmmm ")&ordinalnumber(DAY(NOW())) & TEXT(NOW(),", yyyy")

Returns March 4th, 2010


Gord Dibben MS Excel MVP


On Thu, 4 Mar 2010 16:49:49 +0000, Keyrookie
wrote:


Is there a way to have dates show with extensions like, "st", "nd",
"rd", "th"
when using the NOW() formula? In other words, when the date changes
from the 1st to the 2nd will Excel display the extensions? Or, is
there a way automatically to spell out the dates, (First, Third,
Sixteenth, etc.) using the NOW() or some other formula?

Thanks,
K


  #3  
Old March 4th, 2010, 08:54 PM posted to microsoft.public.excel.worksheet.functions
Squeaky
external usenet poster
 
Posts: 131
Default Date abbreviations / extensions

Hi Keyrookie,

One way: Place 1 through 31 in a column (I used G1-g31). In column H put
1st, 2nd, 3rd, etc, or spell the words out if you wish.

In another cell put:

=VLOOKUP(DAY(NOW()),(F1:G31),2,FALSE)

You can hide G and H columns if you wish.

Squeaky


"Keyrookie" wrote:


Is there a way to have dates show with extensions like, "st", "nd",
"rd", "th"
when using the NOW() formula? In other words, when the date changes
from the 1st to the 2nd will Excel display the extensions? Or, is
there a way automatically to spell out the dates, (First, Third,
Sixteenth, etc.) using the NOW() or some other formula?

Thanks,
K




--
Keyrookie
.

  #4  
Old March 5th, 2010, 08:15 PM posted to microsoft.public.excel.worksheet.functions
Keyrookie[_56_]
external usenet poster
 
Posts: 1
Default Date abbreviations / extensions


Gord,

I tried your function but fell short. I'm assuming UDF stands for User
Defined Function? I copied your code and pasted it into the worksheet
code and then copied the formula into a cell. Nothing happened. What
did I do wrong?

K

Gord Dibben;933874 Wrote:
One method using a UDF

Function OrdinalNumber(ByVal Num As Long) As String
Dim N As Long
Const cSfx = "stndrdthththththth"
N = Num Mod 100
If ((Abs(N) = 10) And (Abs(N) = 19)) _
Or ((Abs(N) Mod 10) = 0) Then
OrdinalNumber = Format(Num) & "th"
Else
OrdinalNumber = Format(Num) & Mid(cSfx, _
((Abs(N) Mod 10) * 2) - 1, 2)
End If
End Function

In a cell enter

=TEXT(NOW(),"mmmm ")&ordinalnumber(DAY(NOW())) & TEXT(NOW(),", yyyy")

Returns March 4th, 2010


Gord Dibben MS Excel MVP


On Thu, 4 Mar 2010 16:49:49 +0000, Keyrookie
wrote:
-

Is there a way to have dates show with extensions like, "st", "nd",
"rd", "th"
when using the NOW() formula? In other words, when the date changes
from the 1st to the 2nd will Excel display the extensions? Or, is
there a way automatically to spell out the dates, (First, Third,
Sixteenth, etc.) using the NOW() or some other formula?

Thanks,
K-





--
Keyrookie
  #5  
Old March 6th, 2010, 09:47 AM posted to microsoft.public.excel.worksheet.functions
Roger Govier[_8_]
external usenet poster
 
Posts: 338
Default Date abbreviations / extensions

HI

you need to copy Gord's function code to a standard module, not to the
Worksheet itself.

Alt+F11 to invoke the VB Editor
InsertModule
Paste code into white pane that appears
Alt+F11 to return to Excel
--
Regards
Roger Govier

Keyrookie wrote:
Gord,

I tried your function but fell short. I'm assuming UDF stands for User
Defined Function? I copied your code and pasted it into the worksheet
code and then copied the formula into a cell. Nothing happened. What
did I do wrong?

K

Gord Dibben;933874 Wrote:
One method using a UDF

Function OrdinalNumber(ByVal Num As Long) As String
Dim N As Long
Const cSfx = "stndrdthththththth"
N = Num Mod 100
If ((Abs(N) = 10) And (Abs(N) = 19)) _
Or ((Abs(N) Mod 10) = 0) Then
OrdinalNumber = Format(Num) & "th"
Else
OrdinalNumber = Format(Num) & Mid(cSfx, _
((Abs(N) Mod 10) * 2) - 1, 2)
End If
End Function

In a cell enter

=TEXT(NOW(),"mmmm ")&ordinalnumber(DAY(NOW())) & TEXT(NOW(),", yyyy")

Returns March 4th, 2010


Gord Dibben MS Excel MVP


On Thu, 4 Mar 2010 16:49:49 +0000, Keyrookie
wrote:
-
Is there a way to have dates show with extensions like, "st", "nd",
"rd", "th"
when using the NOW() formula? In other words, when the date changes
from the 1st to the 2nd will Excel display the extensions? Or, is
there a way automatically to spell out the dates, (First, Third,
Sixteenth, etc.) using the NOW() or some other formula?

Thanks,
K-





  #6  
Old March 6th, 2010, 09:44 PM posted to microsoft.public.excel.worksheet.functions
Gord Dibben
external usenet poster
 
Posts: 20,252
Default Date abbreviations / extensions

Thank for the assist Roger.

I usually post the instructions but in a hurry or simply forgot.

I would guess the latterg


Gord

On Sat, 06 Mar 2010 09:47:19 +0000, Roger Govier
wrote:

HI

you need to copy Gord's function code to a standard module, not to the
Worksheet itself.

Alt+F11 to invoke the VB Editor
InsertModule
Paste code into white pane that appears
Alt+F11 to return to Excel


  #7  
Old March 8th, 2010, 10:59 PM posted to microsoft.public.excel.worksheet.functions
Keyrookie[_57_]
external usenet poster
 
Posts: 1
Default Date abbreviations / extensions


Gord Dibben;934452 Wrote:
Thank for the assist Roger.

I usually post the instructions but in a hurry or simply forgot.

I would guess the latterg


Gord

On Sat, 06 Mar 2010 09:47:19 +0000, Roger Govier
wrote:
-
HI

you need to copy Gord's function code to a standard module, not to the


Worksheet itself.

Alt+F11 to invoke the VB Editor
InsertModule
Paste code into white pane that appears
Alt+F11 to return to Excel-


Thanks Gord & Roger,

I copied the function into a module and it worked fine. One last
puzzle piece...

In cell O154 I have this formula:
=NOW()
In cell Q154 this formula:
=DATE(YEAR(O154),MONTH(O154),1+7*2)-WEEKDAY(DATE(YEAR(O154),MONTH(O154),8-1))

This gives me the 2nd Sunday of every month. I'm wanting this cell,
Q154, to show the extensions. How do I combine the formula I'm already
using and the new one that will reflect the extensions? For this month
cell Q154 would show 14th. For next month it would show 11th.

Thanks again,

K




--
Keyrookie
 




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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 08:51 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.