Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Changing Date Formats in VBA
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? |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
changing date formats | Excel Discussion (Misc queries) | |||
changing date formats | Excel Worksheet Functions | |||
Changing date formats? | Excel Discussion (Misc queries) | |||
Changing Imported Date Formats | Excel Worksheet Functions | |||
Changing Imported Date Formats | Excel Worksheet Functions |