Need help to build condition choosing date with three scenarios as shown in figure!

I have six dates. I need to build condition for that date so that when today is x date (also check days), I need to select date -3 or -4 or -2. The date with conditions are in figure below
image

What I want is:

  • In a year whenever the date mentioned above comes up… I need to run a condition so that it clicks the date in calendar I want it to click>
    For eg: If todays date matches the date in condition it should click -4 (could be -3 or -2) and choose that date otherwise if it doesnot match it should click -1 or -2 ( given i have condition to check if its monday select -2 and other days select -1)

For the rest of the date in a year… I have developed a condition if todays date is x and is monday select -2 to choose friday date… and for the rest of the day just choose yesterdays date.

I don’t know if I am clear enough but I would appreciate any help. Thank you

Hello @RamboRocky

I’m not sure if I understand right, but I think you can achieved this using
auxiliary file to make easy you add or remove dates.

So, let’s assume you have this

image

Now you can use in assign activity something like this:

string_date_variable = if(dt_DateRules.Select(“[Date] = '”+DateTime.Now.ToString(“dd/MM/yyyy”)+“’ “).Any() , DateTime.Now.AddDays(CInt(dt_DateRules.Select(”[Date] = '”+DateTime.Now.ToString(“dd/MM/yyyy”)+"’ ").First().Item(“Rule”).ToString)).ToString(“dd/MM/yyyy”),DateTime.Now.AddDays(-1).ToString(“dd/MM/yyyy”))

Where DateTime.Now.AddDays(-1) is the default date for other dates. You can change as needed it.

Using auxiliary file make easy to add, remove or change the dates without need to change your code in the future. You just add into file, set which is the rule and done. It reflect in your code

Now you already have the date, just change your flow to use it when need to select the date.

1 Like

Hi @RamboRocky ,

Please extract the dates using regex first and use date varlable with AddDays method to order to get the date which needs to be selected

1 Like

Hi could you provide me some example with on regex expression please?

Hi, So doing these does it matches todays date with the date in excel and then setup the rule accordingly? Can you elaborate what the code is doing please?

Thanks this helped :slight_smile:

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