Is today before the specific date this year in a if statement


I automated 4 extractions with UiPath studio. Each extraction is for a quarter of the year
Q1 ends on March 31st.
Q2 ends on June 30th.
Q3 ends on September 30th.
Q4 ends on December 31st.

So I would like to make 4 if statement saying:
If today’s date is March 31st or before, do the first extraction, else do not
If today’s date is June 30th or before, do the second extraction, else do not
Same goes for the 2 others.

Is it possible to wildcard the year or I would have to change my variable next year (because if I compare it to 31.03.2020, on January 1st 2021 I would still be after, but in fact before March 31st.

For the moment, I created 4 DateTime Variable with the expression : convert.ToDateTime(“03/31/2020”) by example. I then compare it to Today’s date and it works. I would like to the the same, but without considering the year.

Thank you really much for help, it is really appreciated


@BOYER_Tommy, I think this is a perfect use case for a Switch Case activity, but the if will still do the job.

you will not need to necessarily change your year variable every year, you could parse a value like this to your variable: "31.03." + Year(Now).ToString,
when you print this out, it will look like this: 31.03.2020 and the year will update itself to match current year.

1 Like

this should give you an idea on how to compare dates:



The following expression will give you the chosen DateTime’s quarter (here for today) as an Integer from 1 to 4. You can use a switch on it, etc.

DatePart(DateInterval.Quarter, DateTime.Now)

1 Like

Hi Senzo,

Thank you really much, it is now working (tried with your formula for a good moment and realized that it was my Today’s formula which was not good (worked before but with the new formula didn’t work, I do not know why, but doesn’t matter now :wink:.) I found the good way to write my today’s formula within the reply you sent :smiley:

Thank you for your help, it is really appreciated

1 Like

Hi msan,

I could solve the problem with the 1st reply, but thank you for the reply, I hope this can be useful for someone with a problem similar to mine in the future.

Have a nice day! :smiley:

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