Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default Time formatting

fname = format(date,"mmddyyyy")

might work for you.



jeffP wrote:

Hello all,
I'm trying to get this to show leading zeros but I'm stuck. I'm using it to
SaveAs a filename so it must be text without special characters, etc.
It works fine except single days (1-9)would show poorly 642004 (June 4th)
is hard to read and minutes are worse. Zero to 9 shows no leading 0 thus
8:05 PM would be 185 instead of military 1805.
Any help would be appreciated.
Dim fname As String
Dim tname As String

fname = Format$(month(Now()) & Day(Now()) & Year(Now()),
"@@@@@@@@_")
tname = Format$(Hour(Now()) & Minute(Now()), "@@@@_")

--
jeff


--

Dave Peterson

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default Time formatting

oops. I read J.E.'s message and see that I forgot the time.

Maybe an alternative:

fname = format(now,"mmddyyyy hhmmss")

And I agree with J.E. about yyyymmdd.

Dave Peterson wrote:

fname = format(date,"mmddyyyy")

might work for you.

jeffP wrote:

Hello all,
I'm trying to get this to show leading zeros but I'm stuck. I'm using it to
SaveAs a filename so it must be text without special characters, etc.
It works fine except single days (1-9)would show poorly 642004 (June 4th)
is hard to read and minutes are worse. Zero to 9 shows no leading 0 thus
8:05 PM would be 185 instead of military 1805.
Any help would be appreciated.
Dim fname As String
Dim tname As String

fname = Format$(month(Now()) & Day(Now()) & Year(Now()),
"@@@@@@@@_")
tname = Format$(Hour(Now()) & Minute(Now()), "@@@@_")

--
jeff


--

Dave Peterson


--

Dave Peterson

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
Help with time formatting Tom Excel Discussion (Misc queries) 3 December 14th 08 06:33 PM
Time formatting MD Excel Worksheet Functions 3 June 28th 07 11:49 PM
Formatting / Time lehigh46 Excel Worksheet Functions 3 July 25th 05 07:48 PM
time formatting and time categorizing (vlookup or data validation) MarianneR Excel Worksheet Functions 4 November 18th 04 03:24 PM
time formatting and time categorizing (vlookup or data validation) MarianneR Excel Worksheet Functions 0 November 18th 04 03:13 PM


All times are GMT +1. The time now is 07:47 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"