How to format date as ddd, mmm, (date)

G

gerry.lisa

I would like Sunday, October 01, 2006

to show up as Sun Oct 1st

Thanks for your help!

....Lisa...Excel 2003
 
P

Peo Sjoblom

Excel dates are days since Jan 00 1900 so one day is 1 etc. If you type in
(assuming you are using US date formats) 10/01/06 in a cell, then use custom
format ddd mmm d it will return Sun Oct 1, you can't format for ordinals
like 1st, 2nd 3rd etc, you would need either an event macro or a formula in
another cell and neither is really a good solution. You can of course type
in Sun Oct 1st but it will be text



--


Regards,

Peo Sjoblom

Excel 95 - Excel 2007
Northwest Excel Solutions
www.nwexcelsolutions.com
(remove ^^ from email)
 
G

gerry.lisa

Thanks Peo!!
I didn't realize "d" would give me the numerical date, I thought the
"d's" were just for the days of the week. I think I can manage without
the ordinals.

....Lisa
 
G

Gord Dibben

Good find Barbara.

Following the thread to Ron Rosenfield's event code gives another choice of
adding the ordinals without using an extra column.


Gord Dibben MS Excel MVP
 
B

Barbara Wiseman

Gordon,
Thank you, I have found the code on a different newsgroup thread.
I do not use macros much, but managed to get it to work.

Lisa,
As I had managed to get it to work I thought I would put the exact details
of how to do it, much thanks to Ron Rosenfeld.

Right click on the worksheet tab.
Select View Code from the dropdown menu.
Paste the code below into the window that opens.


=============================
Option Explicit


Private Sub Worksheet_Change(ByVal Target As Range)
Dim aoi As Range, c As Range
Dim Suffix As String


Set aoi = [a1:a100] 'set this to where you might be entering dates


On Error GoTo Handler


If Not Intersect(Target, aoi) Is Nothing Or _
Not Intersect(Target.Dependents, aoi) Is Nothing Then


For Each c In aoi
If IsDate(c.Value) Then
Select Case Day(c.Value)
Case Is = 1, 21, 31
Suffix = "\s\t"
Case Is = 2, 22
Suffix = "\n\d"
Case Is = 3, 23
Suffix = "\r\d"
Case Else
Suffix = "\t\h"
End Select


c.NumberFormat = "mmm d" & Suffix & " yyyy"
End If
Next c


End If
Exit Sub


Handler: If Not Intersect(Target, aoi) Is Nothing Then Resume Next
If Err.Description <> "No cells were found." Then
MsgBox ("Error #" & Err & " " & Err.Description)
End If
End Sub

=============================
Now if you enter a date (or just edit it) it should appear with the ordinal

As I am in the UK I changed the Number format line to
c.NumberFormat = "ddd d" & Suffix & " mmm" & " yyyy"
Which gave me
Mon 28th Aug 2006


The original code gives
Aug 28th 2006


Good Luck, Barbara.
 
Top