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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Concatenate a FileName String with Date and Time 1

Status
Not open for further replies.

meny21

IS-IT--Management
Oct 4, 2002
101
MX
Hi Guys,

I almost got it but I decided your opinion on this:

I have a String Variable called "MyFileName" and I Would like to concatenate with date and Time, Example:

MyFileName = MyFileName & "_" & Year(Date) & "_" & Month(Date) & "_" & Day(Date)

With this I have two questions:

1 - It works, but the month or the day when is one digit (For example January) it comes in "1" and not "01".

2 - How can I put the Time here, the issue here is that I don't need spaces only the hour, minute and seconds.

The output of my variable will be like this:

"MyFileName_2008_01_16_181054" (181054 will be the hour)

I tried with Hour(time) but the VB 6.0 I don't know why It doesn't accept it.

Thanks for any suggestions

Regards

MR





 




Hi,

Check out the Format function
Code:
MyFileName = MyFileName & "_" & Format(Now, "yyyy_mm_dd_hhmmss")

Skip,

[glasses] When a diminutive clarvoyant had disappeared from detention, headlines read...
Small Medium at Large[tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top