Help with the "Day of Week" function and its loop!

Goodmorning everyone,

I’m working on a project without the orchestrator and I should work on an excel file that I find in a folder.
This file must be processed today -1 except on Saturdays and Sundays.
It occurred to me to use the DayOfWeek function, so when the robot finds “Monday” instead of doing today -1, I do today -2.
But it happens that I don’t know how to do the “if” for each day.

Some idea?

Thanks in advance!

image

1 Like

Hi @Araceli91

You can try this

If(
	{"Saturday", "Sunday"}.Contains(Now.DayOfWeek.ToString),
	"Do Not Process",
	If(
		Now.DayOfWeek.ToString.Equals("Monday"),
		Now.AddDays(-3).DayOfWeek.ToString,
		Now.AddDays(-1).DayOfWeek.ToString
		)
	)

If today is Monday it will give Friday
For Tue to Friday it will give Mon to Thu

Use it in assign Activity

image

your flow seems correct

You can put the IF condition and mention expression

Now.dayoftheweek.tostring = “Sunday” or Now.dayoftheweek.tostring = “Saturday”

I will try the two solutions and tell you how it was!

Thanks so much!

I am trying your solution right now, do you know if it is possible to convert the day it comes back to me (For example "Friday) to date (11/05/2021)

@Araceli91

grafik
now.AddDays({-2,-3,-1,-1,-1,-1,-1}(now.DayOfWeek))

checked on a test series:
grafik

find starter help here:
GetPreviousWorkday.xaml (5.4 KB)

1 Like

OMG!! omg thank so so much!!!

I finally solved it! I share the function, I hope it will be useful to you.

ControlloGiorniLavorativi.xaml (7.5 KB)

:smiley:

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