I want to have on an input form a start date and a number of months field and then calculate the end date to be that number of months after the start date. The end date will also be an attribute like start date and increment number of months.
Best answer by Community Expert
Hello, you can definitely achieve this by using C# expression to calculate the End Date.
Assuming you have all 3 as Var (2 date type and 1 num), in an Update Variable step the End Date var will have this value
To add any number of days to a provided date
//Get the variable containing your date/time, parse it, and add or subtract days indicated (by indicating a positive or negative number)
DateTime.Parse(GetVariableValue("StartDate")).AddDays(GetVariableValue("NoOfDays"))
Remember: the expression above does not take into account just business working days. in that case i would use this expression to calculate it:
//Create a new variable called 'current', and set it to the system dateTime for today
var current = System.DateTime.Today;
//Create a variable called 'daysToAdd' and load it with the number from your workflow variable
var daysToAdd = Int32.Parse(GetVariableValue("YOUR_VARIABLE").ToString());
//Add days until the number of indicated days is reached
for (var i = 0; i < daysToAdd; i++) {
if (current.DayOfWeek != DayOfWeek.Friday) {
current = current.AddDays(1);
}
else {
current = current.AddDays(3);
}
}
return current;
Reply
Sign up
Already have an account? Login
You can login or register as either a Docusign customer or developer. If you don’t already have a Docusign customer or developer account, you can create one for free when registering.
Customer Login/Registration Developer Login/RegistrationJoin the Docusign Community by logging in with your Docusign developer or customer account credentials.
Don’t have an account? You can create a free one when registering.
Note: Partner-specific logins are not available yet. Partners should log in as either a customer or developer
Docusign Community
You can login or register as either a Docusign customer or developer. If you don’t already have a Docusign customer or developer account, you can create one for free when registering.
Customer Login/Registration Developer Login/RegistrationEnter your E-mail address. We'll send you an e-mail with instructions to reset your password.