View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips Bob Phillips is offline
external usenet poster
 
Posts: 10,593
Default Changing Date Formats in VBA

Use this function

Function OrdinalDate(inDate As Date)
Dim tmp
If Day(inDate) = 11 Or Day(inDate) = 12 Or Day(inDate) = 13 Then
tmp = "th"
ElseIf Right(Day(inDate), 1) < 4 Then
Select Case Right(Day(inDate), 1)
Case 1: tmp = "st"
Case 2: tmp = "nd"
Case 3: tmp = "rd"
End Select
Else
tmp = "th"
End If
OrdinalDate = Day(inDate) & tmp & Format(inDate, " mmmm yyyy")
End Function

like so

ActiveWorkbook.SaveAs Filename:= OrdinaDate(Date)

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"PhilM" wrote in message
ps.com...
Hi

I have a date format of dd/mm/yyyy in a string (ie 02/10/2006) for
filename purposes to save my file I need this to format as "2nd October
2006" how can I do this?