Link to home
Start Free TrialLog in
Avatar of isnoend2001
isnoend2001Flag 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 ?
ASKER CERTIFIED SOLUTION
Avatar of Rgonzo1971
Rgonzo1971

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of isnoend2001

ASKER

The Time sb
Dy0630.rtf would be 0630 with the Dy and .rtf removed
Avatar of Rgonzo1971
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