Avatar of isnoend2001
isnoend2001
Flag for United States of America asked on

format file names to be used as dates

I am trying to remove the file extensions and any letters from file names so i can use them as dates
in one call
example: call to function
function RemoveFileName(Name as  string) as string
remove here
end function
calling function
dim myDate as date
mydate = RemoveFileName("9-20-2015.rtf") or
mydate = RemoveFileName("Mo10-25-2016.rtf")


9-20-2015.rtf
9-21-2015.rtf
9-25-2015.rtf
Yr9-20-2015.rtf
Yr10-25-2016.rtf
Dy1000.rtf'time
Wk10-25-2016.rtf
Mo10-25-2016.rtf
Yr10-25-2016.rtf
Wk10-25-2016.rtf
10-22-2016.rtf
10-21-2016.rtf
11-25-2016.rtf
Yr9-20-2016.rtf
Yr10-25-2016.rtf
Dy10-25-2016.rtf
Wk3-25-2016.rtf
Mo10-25-2016.rtf
Yr5-25-2016.rtf
Wk9-25-2016.rtf
Dy0630.rtf'time
Dy0900.rtf'time
Wk10-25-2016.rtf
Yr10-25-2016.rtf
Wk10-25-2016.rtf

Open in new window

not sure if this a proper name format for a date
10-25-2016
how can this be written ?
Visual Basic Classic

Avatar of undefined
Last Comment
Rgonzo1971

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Rgonzo1971

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
isnoend2001

ASKER
The Time sb
Dy0630.rtf would be 0630 with the Dy and .rtf removed
Rgonzo1971

then try

Function removeFilename(strDate As String) As Date
Select Case UCase(Left(strDate, 2))
    Case "WK", "YR", "MO", "DY"
        Res = Left(Right(strDate, Len(strDate) - 2), Len(strDate) - 6)
    Case Else
        Res = Left(strDate, Len(strDate) - 4)
End Select
removeFilename = Res
End Function

Open in new window

I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck