Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Help formatting date and time

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,56879
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Help formatting date and time
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Help formatting date and time - 2/19/2008 12:58:13 PM   
  kenm

 

Posts: 4
Score: 0
Joined: 2/19/2008
Status: offline
Hello all,

I'm writing a function to output the current time and date, and I'm trying to display the month, day, year,... hour, minute, and second in a 2-digit format without any dashes or slashes, so it should always display twelve character (ex: 021908083830).
I've found a selection of characters that will achieve the 2-digit format (ex: %m for 2 digit month, %y for 2-digit year, etc...), but I can't figure out the proper way to include them in my code. I've included the code I already have. Any ideas? Thanks in advance

-Kenm

Function GetUniqueId

Dim strDateTime
strDateTime = FormatDateTime(now(), vbGeneralDate)

strDateTime = Replace(strDateTime, "/", "", 1, Len (strDateTime), 1)
strDateTime = Replace(strDateTime, ":", "", 1, Len (strDateTime), 1)
strDateTime = Replace(strDateTime, " ", "", 1, Len (strDateTime), 1)
GetUniqueId = strDateTime

End Function
 
 
Post #: 1
 
 RE: Help formatting date and time - 2/19/2008 3:36:59 PM   
  dm_4ever


Posts: 2641
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
Just an example of one way...


      

_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to kenm)
 
 
Post #: 2
 
 RE: Help formatting date and time - 2/20/2008 12:43:53 PM   
  kenm

 

Posts: 4
Score: 0
Joined: 2/19/2008
Status: offline
Thank you...worked like a charm!

kenm

(in reply to dm_4ever)
 
 
Post #: 3
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Help formatting date and time Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts