Switch or IF

Hi everyone!

Newbie here. I’m looking to add a date to a field, the format should be dd/MM/yyyy. The question is. I want the automation to go as…

If TODAY is MONDAY then enter previous FRIDAY date, otherwise, enter YESTERDAY.

Which function will work great IF or SWITCH? How would I write this is UIPATH.

Many thanks!


an IF will do in this case
The logic is=
1 . if Now.DayOfWeek=1 (if today is monday),
a) the date is Now.AddDays(-3).ToString("dd/MM/yyyy") (meaning -3 days from today to get the previous Friday)

b) Otherwise, the date is Now.AddDays(-1).ToString("dd/MM/yyyy") (meaning -1 days from today to get YESTERDAY)
Note the date will be in dd/MM/yyyy format because we specified .ToString(“dd/MM/yyyy”)

Yes!!! Thank you Jack. This works perfectly.

1 Like

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