I have a from date field in the main argument which can be of any format

I have a FromDate argument in the main , the input to the argument can be in any forms like ,

From date : currentdate + dispLastRundate (fully string statements)
FromDate: currentdate - lastrundate
FromDate : current -1
FromDate : current +1
FromDate: lastrundate+1
FromDate: lastrundate-1
FromDate: currentdate+ (any add days)

How can we handle this dynamically in the solution ? Whatever be the input , the solution should work

Hi Ragavi,

To achieve dynamic handling of various date input formats for the “FromDate” argument, you can employ a combination of string manipulation and date calculations. First, you’ll need to evaluate the provided input format and then process it accordingly. For instance, you can use regular expressions to identify the format, extract relevant values like “currentdate,” “lastrundate,” and the operator (“+”, “-”, or no operator), and then perform the necessary date calculations using a language or library with robust date manipulation functions. This way, your solution can intelligently adapt to the diverse input formats while maintaining consistency and accuracy in date handling. The key is to create a flexible, rule-based system that can interpret and compute dates based on the provided input, ensuring the solution remains versatile and functional regardless of the input format.


To handle the dynamic input for the FromDate argument in UiPath, you can use the Evaluate activity along with a combination of UiPath expressions

FromDate = (DateTime.Now.AddDays(If(String.IsNullOrEmpty(input), 0, If(input.Contains("+"), CInt(Regex.Match(input, "[0-9]+").Value), If(input.Contains("-"), -CInt(Regex.Match(input, "[0-9]+").Value), 0)))))
  1. If the input is empty, it defaults to the current date.
  2. If the input contains “+”, it adds the specified number of days to the current date.
  3. If the input contains “-”, it subtracts the specified number of days from the current date.
  4. If the input is “current”, it defaults to the current date.
  5. If the input is “lastrundate+1”, it adds 1 day to the lastrundate…



Assign To: FromDate


System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex(@"(\d{1,2}/\d{1,2}/\d{4})");
System.Text.RegularExpressions.Match match = regex.Match(FromDate);

if (match.Success)

{FromDate = match.Value;}

{Handle different date expressions here}

This expression partially works !

Can you please help me a little bit to achieve my expression ?

For eg .
There is one asset called last run date which will
Hold the date value like : 15/10/2023 (any date )

If from date input is : last run date +1

Or another case
From date : last run date + current date

How to modify this expression . Please help . Thanks in advance


To modify the expression for your specific scenarios

1.For “From date: last run date + 1”:

fromDate = lastRunDate.AddDays(1)

2.For “From date: last run date + current date”:

fromDate = lastRunDate.Add(DateTime.Now.Date)

Make sure to declare and initialize the variables fromDate, lastRunDate, and handle any necessary date formatting if required.


Sorry to trouble you , can you add these two conditions in the main expression of yours and share?


is this ok

fromDate = lastRunDate.AddDays(1).Add(DateTime.Now.Date)



or you can try this

fromDate = lastRunDate.AddDays(1).Add(DateTime.Now.Date).Add(TimeSpan.FromDays(If(String.IsNullOrEmpty(input), 0, If(input.Contains("+"), CInt(Regex.Match(input, "[0-9]+").Value), If(input.Contains("-"), -CInt(Regex.Match(input, "[0-9]+").Value), 0))))


Getting this error


once check the compilers

i think so u given extra braces check once

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.