#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 63
Default Date Format

Hi Greg,

I don't believe you can do this using Format, however you can use a simple
workaround. One thing to mention though is that once you use the ordinal
version of the number then the date will not be recognised as a date by
Excel. So if you are only using your routine to display a date then it is
fine, if you wish to use this date in Excel then you're better off keeping in
the format you already have.

OK, to do what you are asking you need to test the final digit of the day
and then append the characters as necessary. I have used the Format function
twice (either side of the added characters) because otherwise these
characters will be used in the formatting - 4th will become 4t and the h will
display the hour, st, nd and rd also use characters from the Format function,
so the double Format usage is necessary for all.

Select Case Right(Format(Now, "dd"), 1)
Case 1
MAIN.Caption = Format(Now, "hh:mm:ss dddd dd") & "st " & Format(Now, "mmmm
yyyy")
Case 2
MAIN.Caption = Format(Now, "hh:mm:ss dddd dd") & "nd " & Format(Now, "mmmm
yyyy")
Case 3
MAIN.Caption = Format(Now, "hh:mm:ss dddd dd") & "rd " & Format(Now, "mmmm
yyyy")
Case Else
MAIN.Caption = Format(Now, "hh:mm:ss dddd dd") & "th " & Format(Now, "mmmm
yyyy")
End Select

I hope this helps.

Sean.
--
(please remember to click yes if replies you receive are helpful to you)


"Greg B" wrote:

I am wondering how I can make the vba to add the extensions to the date i.e.
24 to go to the 24th
23 to 23rd
etc
Thanks
here is the code I am using
MAIN.Caption = Format(Now, "hh:mm:ss" & " " & "dddd dd mmmm yyyy")



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Date Format

Thanks SeanC
Absolutely perfect for what i needed.

Thanks Once Again

Greg
"SeanC UK" wrote in message
...
Hi Greg,

I don't believe you can do this using Format, however you can use a simple
workaround. One thing to mention though is that once you use the ordinal
version of the number then the date will not be recognised as a date by
Excel. So if you are only using your routine to display a date then it is
fine, if you wish to use this date in Excel then you're better off keeping
in
the format you already have.

OK, to do what you are asking you need to test the final digit of the day
and then append the characters as necessary. I have used the Format
function
twice (either side of the added characters) because otherwise these
characters will be used in the formatting - 4th will become 4t and the h
will
display the hour, st, nd and rd also use characters from the Format
function,
so the double Format usage is necessary for all.

Select Case Right(Format(Now, "dd"), 1)
Case 1
MAIN.Caption = Format(Now, "hh:mm:ss dddd dd") & "st " & Format(Now, "mmmm
yyyy")
Case 2
MAIN.Caption = Format(Now, "hh:mm:ss dddd dd") & "nd " & Format(Now, "mmmm
yyyy")
Case 3
MAIN.Caption = Format(Now, "hh:mm:ss dddd dd") & "rd " & Format(Now, "mmmm
yyyy")
Case Else
MAIN.Caption = Format(Now, "hh:mm:ss dddd dd") & "th " & Format(Now, "mmmm
yyyy")
End Select

I hope this helps.

Sean.
--
(please remember to click yes if replies you receive are helpful to you)


"Greg B" wrote:

I am wondering how I can make the vba to add the extensions to the date
i.e.
24 to go to the 24th
23 to 23rd
etc
Thanks
here is the code I am using
MAIN.Caption = Format(Now, "hh:mm:ss" & " " & "dddd dd mmmm yyyy")





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
permanent conversion of 1904 date format to 1900 date format Jos Excel Worksheet Functions 4 November 26th 15 02:48 PM
change date format dd/mm/yyyy to Julian date format? itzy bitzy Excel Worksheet Functions 1 December 8th 09 07:42 PM
convert serial date format to normal date format Flagworld Excel Discussion (Misc queries) 3 September 23rd 08 01:32 PM
code to convert date from TEXT format (03-02) to DATE format (200203) Gauthier[_2_] Excel Programming 0 September 22nd 04 03:26 PM
Change a date in text format xx.xx.20xx to a recognised date format concatenator Excel Programming 1 November 24th 03 11:33 PM


All times are GMT +1. The time now is 02:06 PM.

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

About Us

"It's about Microsoft Excel"