Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 01-10-2013, 02:55 AM
AndyDDUK AndyDDUK is offline Format as eg "17th January" Windows 7 64bit Format as eg "17th January" Office 2010 64bit
Advanced Beginner
Format as eg "17th January"
 
Join Date: Oct 2012
Posts: 32
AndyDDUK is on a distinguished road
Default Format as eg "17th January"

Hi


I'm using an excel macro to format dates

I need to format as eg "17th January" or "2nd March" type format

Please help

Many thanks
Reply With Quote
  #2  
Old 01-10-2013, 03:34 AM
JohnWilson JohnWilson is offline Format as eg "17th January" Windows 7 64bit Format as eg "17th January" Office 2010 32bit
Programmer
 
Join Date: Nov 2008
Location: UK
Posts: 1,913
JohnWilson has a spectacular aura aboutJohnWilson has a spectacular aura about
Default

AFAIK Andy there's no built in way.
Try:

Sub getdate()
MsgBox getDay(Day(Now)) & " " & MonthName(Month(Now))
End Sub

Function getDay(dayNum As Long) As String
Select Case dayNum
Case Is = 1, 21, 31
getDay = dayNum & "st"
Case Is = 2, 22
getDay = dayNum & "nd"
Case Is = 3, 23
getDay = dayNum & "rd"
Case 4 To 30
getDay = dayNum & "th"
End Select
End Function
__________________
Microsoft PowerPoint MVP 2007-2023
Free Advanced PowerPoint Tips and Tutorials
Reply With Quote
  #3  
Old 01-10-2013, 04:05 AM
AndyDDUK AndyDDUK is offline Format as eg "17th January" Windows 7 64bit Format as eg "17th January" Office 2010 64bit
Advanced Beginner
Format as eg "17th January"
 
Join Date: Oct 2012
Posts: 32
AndyDDUK is on a distinguished road
Default

Many thanks

If I have my dates (eg 01/01/2012) in cell A1, how do i modify?

Cheers
Reply With Quote
  #4  
Old 01-10-2013, 04:14 AM
JohnWilson JohnWilson is offline Format as eg "17th January" Windows 7 64bit Format as eg "17th January" Office 2010 32bit
Programmer
 
Join Date: Nov 2008
Location: UK
Posts: 1,913
JohnWilson has a spectacular aura aboutJohnWilson has a spectacular aura about
Default

Are you in Excel (This is the PowerPoint section!)

Maybe:

Sub getdate()
Dim myDate As Date
myDate = ActiveSheet.Range("A1")
ActiveSheet.Range("A1") = getDay(Day(myDate)) & " " & MonthName(Month(myDate))
End Sub

Function getDay(dayNum As Long) As String
Select Case dayNum
Case Is = 1, 21, 31
getDay = dayNum & "st"
Case Is = 2, 22
getDay = dayNum & "nd"
Case Is = 3, 23
getDay = dayNum & "rd"
Case 4 To 30
getDay = dayNum & "th"
End Select
End Function
__________________
Microsoft PowerPoint MVP 2007-2023
Free Advanced PowerPoint Tips and Tutorials
Reply With Quote
  #5  
Old 01-10-2013, 04:38 AM
AndyDDUK AndyDDUK is offline Format as eg "17th January" Windows 7 64bit Format as eg "17th January" Office 2010 64bit
Advanced Beginner
Format as eg "17th January"
 
Join Date: Oct 2012
Posts: 32
AndyDDUK is on a distinguished road
Default

This works a treat thank you!

Sorry...yes I appear to be in the wrong forum

Have a good day
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to edit the "Format" and the "show level" of an EXISTING table of content? Jamal NUMAN Word 2 08-14-2011 10:46 AM
Format as eg "17th January" How to know the "format" of the "table of content"? Jamal NUMAN Word 2 07-08-2011 02:24 AM
Format as eg "17th January" How to choose a "List" for certain "Heading" from "Modify" tool? Jamal NUMAN Word 2 07-03-2011 03:11 AM
Format as eg "17th January" Why the "table of contents" doesn't take the same format of the "headings"? Jamal NUMAN Word 5 06-15-2011 10:14 AM
Format as eg "17th January" "Format" tab has no "Picture" Cara Drawing and Graphics 2 05-20-2011 10:13 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 08:33 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft