Creating If conditions that use OR

Hello, I was looking to create an if condition to create the following.
Store Open Date
OR
Version Effective Date
have PRIOR YEAR date, then Start Depr Date should be listed as 1/1/XXXX of CURRENT YEAR
AND Then
SUBTRACT # of months passed (include mnth start date/version effective date) from the listed Lease term
(take lease term and subtract it from the months it has been opened including the first month)

Here is what I have so far.
if(Currentrow.ByField(“Store Open Date”) or CurrentRow.ByField(“Version Eff Date”)=DateTime.Now.AddYears(-1).Year, “1/1/yyyy”,“”)

Thank you in advance

Hi @irma.viramontes

Can you share the screenshot of your workflow so it would be easy to frame the if condition. Hope I might find a solution and any dummy excel from which you are reading data. It will be very useful.

Regards,

Hi @irma.viramontes
Try using the below condition in the If block.

(CurrentRow.ByField(“Store Open Date”).Equals(DateTime.Now.AddYears(-1).Year.ToString()) Or CurrentRow.ByField(“Version Eff Date”).Equals(DateTime.Now.AddYears(-1).Year.ToString()), “1/1/” + DateTime.Now.Year.ToString(), “”)

Please do revert back if it works.
Hope it helps. Happy automation.

Regards,

Hi @irma.viramontes

Can you try this-

If (CurrentRow.ByField(“Store Open Date”).Year = DateTime.Now.AddYears(-1).Year Or
CurrentRow.ByField(“Version Eff Date”).Year = DateTime.Now.AddYears(-1).Year) Then
start_depr_date = “1/1/” & DateTime.Now.Year.ToString
months_passed = DateTime.Now.Month - 1
adjusted_lease_term = lease_term - months_passed
Else
start_depr_date = “”
adjusted_lease_term = lease_term
End If

Thanks!!

Thanks to you both. I will give these a try.

Hi @irma.viramontes ,

This could simply be checked by comparing the years of the dates, you do not need the whole date from last year,

DateTime.ParseExact(currentRow(“Store Open Date”).toString, “dd/MM/yyyy”, Globalization.CultureInfo.InvariantCulture).Year=Now.AddYears(-1).Year Or DateTime.ParseExact(currentRow(“Version Eff Date”).toString, “dd/MM/yyyy”, Globalization.CultureInfo.InvariantCulture).Year=Now.AddYears(-1).Year

That should work.

Thank you!

IF the solution works,

Please mark topic as solution.

Thanks

Hi @irma.viramontes

If you found the solution. Please make the mark as solution to close the loop.

Best Regards.

You don’t put an If expression in the Condition of your If/Else If.

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