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

Format Date dd-mm-yy to yyyymmdd 2

Status
Not open for further replies.

comnetlimited

Technical User
Oct 7, 2003
68
PG
Hello folks,
I capture the string date in the format dd-mm-yy from a file name and I want to create a folder which reflects that date in the format yyyymmdd

For eg:
File Name = "Statement as at 30-11-05 for Joe.pdf"
String Date = 30-11-05
Folder Name = 20051130

I will appreciate if someone provide me a tip.

Thanks
 
If you have a valid date, you can simply use functions like...

Year(myDate)
Month(myDate)
Day(myDate)

...and use string concatenation to build your file name. If you don't have a valid date that VB recognizes, then you'll have to use the instring function.

He who has knowledge spares his words, and a man of understanding is of a calm spirit. Even a fool is counted wise when he holds his peace; when he shuts his lips, he is considered perceptive. - King Solomon
 
Something like this ?
FileName = "Statement as at 30-11-05 for Joe.pdf"
a = Split(FileName,"-")
FolderName = "20" & Left(a(2),2) & a(1) & Right(a(0),2)

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks both.. PHV I did a search on Format Date and used your Tip in thread329-979415.

Thanks alot
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top