Forum Discussion
How to exclude weekends with scheduled flows using Power Automate
- 1 year ago
POSPOS Hello,
here's my proposal.
Recurence every day, then initialize variable as string with this inside of it:
if( and( not(equals(dayOfWeek(addDays(startOfMonth(utcNow()), 14)), 6)), not(equals(dayOfWeek(addDays(startOfMonth(utcNow()), 14)), 0)) ), formatDateTime(addDays(startOfMonth(utcNow()), 14), 'yyyy-MM-dd'), if( and( not(equals(dayOfWeek(addDays(startOfMonth(utcNow()), 15)), 6)), not(equals(dayOfWeek(addDays(startOfMonth(utcNow()), 15)), 0)) ), formatDateTime(addDays(startOfMonth(utcNow()), 15), 'yyyy-MM-dd'), if( and( not(equals(dayOfWeek(addDays(startOfMonth(utcNow()), 16)), 6)), not(equals(dayOfWeek(addDays(startOfMonth(utcNow()), 16)), 0)) ), formatDateTime(addDays(startOfMonth(utcNow()), 16), 'yyyy-MM-dd'), null ) ) )(code basically checks whether 15th, 16th or 17th is weekend and find the earliest non weekend day to run it).
This gonna check what's the valid day for the run in the current month.Then you have a condition that checks if today is that day and you then put the rest of your actions to the "TRUE" branch.
POSPOS Hello,
here's my proposal.
Recurence every day, then initialize variable as string with this inside of it:
if(
and(
not(equals(dayOfWeek(addDays(startOfMonth(utcNow()), 14)), 6)),
not(equals(dayOfWeek(addDays(startOfMonth(utcNow()), 14)), 0))
),
formatDateTime(addDays(startOfMonth(utcNow()), 14), 'yyyy-MM-dd'),
if(
and(
not(equals(dayOfWeek(addDays(startOfMonth(utcNow()), 15)), 6)),
not(equals(dayOfWeek(addDays(startOfMonth(utcNow()), 15)), 0))
),
formatDateTime(addDays(startOfMonth(utcNow()), 15), 'yyyy-MM-dd'),
if(
and(
not(equals(dayOfWeek(addDays(startOfMonth(utcNow()), 16)), 6)),
not(equals(dayOfWeek(addDays(startOfMonth(utcNow()), 16)), 0))
),
formatDateTime(addDays(startOfMonth(utcNow()), 16), 'yyyy-MM-dd'),
null
)
)
)
(code basically checks whether 15th, 16th or 17th is weekend and find the earliest non weekend day to run it).
This gonna check what's the valid day for the run in the current month.
Then you have a condition that checks if today is that day and you then put the rest of your actions to the "TRUE" branch.