Forum Discussion
Is the date the same for every line in the file? Perhaps you could use a project variable and read the value from that instead. It would be a lot easier to increment it there instead of trying to update all those strings.
Yes Year is same for every line in the file , so if i try project variable and increment year each time but need to change year for the first time in variable initialisation because file changes during my testing .
Steps to follow:
if i get the input file , first need to increment the year inside the file and then will import into test application.
- sanjay02886 years agoFrequent Contributor
Hi,
As Marsha_R said there are multiple ways to accomplish the task. If you are looking for regular expression here is a sample script which is being written in vbscript to fetch only the Date value from a string increment it and replace with the incremented value.
Sub Test()
oriDate = GetDateFromString("27/02/1988,09:30,00:25,Slot2,NH New History-2,03,,07,,Comedy,16,,06,,")
replacedDateVal = IncrementAndReplaceYear(oriDate)
MsgBox replacedDateVal
End Sub'' Regular expression to get the dateVal from String
Function GetDateFromString(strToSearch)
Set re = New RegExp
re.Pattern = "(\d{1,2}\/\d{1,2}\/\d{4})|"
Set resStr = re.Execute(strToSearch)
If re.Test(strToSearch) Then
GetDateFromString = resStr(0).Value
Else
GetDateFromString = "date not found!"
End If
End Function'' Increment the year value and replace the year val
Function IncrementAndReplaceYear(dateVal)
yr = Year(dateVal)
replacedVal = ConvertDate(dateVal, yr + 1)
IncrementAndReplaceYear = replacedVal
End FunctionFunction ConvertDate(originalDate, incrementedYear)
dateVal = Day(originalDate)
monthVal = Month(originalDate)
If Len(dateVal) = 1 Then
dateVal = "0" & dateVal
End If
If Len(monthVal) = 1 Then
monthVal = "0" & monthVal
End If
ConvertDate = dateVal & "/" & monthVal & "/" & incrementedYear
End Function
Related Content
Recent Discussions
- 19 minutes agoendorium
- 16 hours agoAivanitskiy
- 19 hours agonastester