Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create Timestamp on filename 1

Status
Not open for further replies.

twooly

MIS
Feb 22, 2004
122
US
Can someone point me in the right direction to create a timestamp on a fileman?

I understand the FormatDateTime function but it outputs in a format like 3/4/2002 11:00 AM

How can I change it to something like 030420041100?

Thanks
 
This is how I do it:
Code:
Function GetDateTimeStamp
  Dim strNow
  strNow = Now()
  GetDateTimeStamp = Year(strNow) & Pad2(Month(strNow)) _
        & Pad2(Day(StrNow)) & Pad2(Hour(strNow)) _
        & Pad2(Minute(strNow)) & Pad2(Second(strNow))
End Function

Function Pad2(strIn)
  Do While Len(strIn) < 2
    strIn = "0" & strIn
  Loop
  Pad2 = strIn
End Function



[blue]"Well, once again my friend, we find that science is a two headed beast. One head is nice, it gives us aspirin and other modern conveniences,...but the other head of science is BAD! Oh, beware the other head of science, Arthur; it bites!!" - The Tick[/blue]
 
Something like this ?
myTimeStamp = Right(Year(Now),2) _
& Right("00" & Month(Now),2) _
& Right("00" & Day(Now),2) _
& Right("00" & Hour(Now),2) _
& Right("00" & Minute(Now),2) _
& Right("00" & Second(Now),2)

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top