The VBScript “DateAdd” allows you to add days to a date. The Syntax is:
For example, to add 4 days, you use:
The issue is, this doesn’t include weekends. However I fell across this solution thanks to Sholsinger:
Function BusinessDayAdd(delta, dt)
dim weeks, days, day
weeks = Fix(delta/5)
days = delta Mod 5
day = DatePart("w",dt)
If (day = 7) And days > -1 Then
If days = 0 Then
days = days - 2
day = day + 2
days = days + 1
day = day - 7
If day = 1 And days < 1 Then
If days = 0 Then
days = days + 2
day = day - 2
days = days - 1
day = day + 6
If day + days > 6 Then days = days + 2
If day + days < 2 Then days = days - 2
BusinessDayAdd = DateAdd("d", (weeks * 7 + days), dt)
To use this function, call it as follows:
The XML “timestamptype” date/time format is as follows:
Recently during a project of integrating systems together and creating XML files, I’ve had to create this in VBScript and SQL.
Here’s the code:
Year(Now) & "-" & Right("0" & Month(Now),2) & "-" & Right("0" & Day(Now),2) & "T" & Right("0" & Hour(Now),2) & ":" & Right("0" & Minute(Now),2) & ":" & Right("0" & Second(Now),2) & ".000000"
As you can see SQL is a lot cleaner than VBScript!
In Taskcentre, the text parser tool can be used to extract text between set characters.
A good example is if you have the following input data:
<Result>This is a test</Result>
And wish to extract the following text:
This is a test
This is a good tool, however doesn’t handle errors very well. For example, if the text is not found, it will throw an error message (unless you tell it to ignore errors), which may impact other steps. Additionally the extracted string may be needed in the middle of a Web Service call.
A solution is to use a VBScript function which will handle these errors gracefully. In the example, the function will return a space character if either of the characters are not found. but this can be changed to anything, e.g. “Error”, “String not Found” etc within the function
Using the function is very simple. The screenshot below shows example code:
In the example, the variable Result1 will be set to “This is a test”, whereas Result2 is not found, so is set to a space character.
Full download of the example is available below:
Select String Between Characters Example Script and Task