Quantcast
Channel: SQL Server Integration Services forum
Viewing all articles
Browse latest Browse all 24688

How to SUBSTRING In the Script Task

$
0
0

In the script task how would you do something like this.....


If the file name is like 'NAV Performance%' or substring(filename, 1, 15)='NAV Performance' then run this code

begin
Dts.Variables.Item("User::FileDate").Value = CDate(Mid(Dts.Variables("FileName").Value.ToString(), 17, 10)).ToString("YYYY-MM-DD")
end

ELSE if the file name like 'NAVPerf_%' or substring(filename, 1, 8)='NAVPerf_' then run this code

Begin
FileDate = Mid(fi.Name, InStr(fi.Name, "_") + 1, 8) 'fi.Name, (Len(fi.Name) - 5)), "_")
FileDay = Right(FileDate, 2)
FileMonth = Mid(FileDate, 5, 2)
FileYear = Left(FileDate, 4)
Dts.Variables.Item("User::FileDate").Value = CDate(FileMonth & "/" & FileDay & "/" & FileYear).ToString("MM/dd/yy")

End


I don't know how to substring in VB in the script task.


lcerni


Viewing all articles
Browse latest Browse all 24688

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>