IF Condition. (If current month is January then..)

I need to create an If-Condition that says “If today/current month is January” then it should copy a file… I have opened the “if condition” activity and I am not sure how to do it.

Hi @maria.mitova

Use the below syntax in if condition
DateTime.Now.ToString(“MMM”)="January"

Then place the copy file activity inside then block of if activity

Thanks
Robin s

as an alternate with less code statement characters:
Now.Month = 1

1 Like

Thank you, both worked! :slight_smile:

I am now trying to find out how to get previous year and month. The code I am using to get previous month is:

now.AddMonths(-1).ToString(“yyyy-MM”)

however, I am not sure how to take the previous year as well. Now is 01-2022 and I need 12-2021.

Thank you!

Hi @maria.mitova

Try out this syntax to get the previous year

Now.AddYears(-1).ToString(“yyyy-MM”)

Thanks
Robin

Hi Robin,

Thank you for your answer! I need to deduct the year and the month. This code will only deduct the year.

2022-01 → 2021-12

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