How to make it so that if my variable contains any value from a datatable it performs a specific action

Hello all,
I am extracting the current date using
image
and using the month to compare with a data table which is as follows:
image
Now what I intend is if the month is present in the data table then it should add 6 months to that date else it should subtract 6 months

I have some log messages along the way to guide me and it tells me that it finds a value that contains, never the less it is subtracting when it should be adding, any idea why?
Output window:
image

Hi,

It’s because you evaluate “06” in the final row and it subtract 6 from currentMonth.
I think it’s easier to use FilterDataTable as the following, if my understanding is correct.

Regards,

Hii @goncalo.rocha ,

You can do this using below code

  1. If the currentMonth is present
    currentMonth.AddMonths(+6).ToString(“MM/yyyy”)

  2. If the currentMonth is not present
    currentMonth.AddMonths(-6).ToString(“MM/yyyy”)

You can refer the attach workflow for your reference.

AddOrSubtractMonth.zip (2.2 KB)

Thanks,

Hey @goncalo.rocha

Just in the if contion use
MonthFinanceVariable = now.AddMonths(+6).ToString(“MM/yyyy”)
in the else condition use
MonthFinanceVariable = now.AddMonths(-6).ToString(“MM/yyyy”)
Rest is fine in your code
I think this will help

Cheers.

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