Power Automate: Find the Given Date is Weekend (Fri 6 PM to Mon 8 AM)

This blog will discuss finding the given date that falls on the weekend or not.

Background:

I have a use case not to send email notifications on weekends when a record is created. It means no email should send on weekends. For their business, the weekend starts Friday at 6 PM and ends Monday at 8 AM.

Requirement:

Find the given date is weekend. In our example, the weekend starts Friday at 6 PM and ends Monday at 8 AM.

Step 1: Compose DateTime

formatDateTime(variables(‘Test DateTime’))

Step 2: Day Of Week

dayOfWeek(outputs(‘Compose_DateTime’))

Day of week Numbers

  • 0 – Sunday
  • 1 – Monday
  • 2 – Tuesday
  • 3 – Wednesday
  • 4 – Thursday
  • 5 – Friday
  • 6 – Saturday

Step 3: Find Is Weekend

or(
equals(outputs(‘DayofWeek’),6),
equals(outputs(‘DayofWeek’),0),
and(equals(outputs(‘DayofWeek’),5), greaterOrEquals(int(formatDateTime(outputs(‘Compose_DateTime’),’HH’)),18)),
and(equals(outputs(‘DayofWeek’),1), less(int(formatDateTime(outputs(‘Compose_DateTime’),’HH’)),8))
)

Notes

  • HH – 24 Hrs Time
  • 18 means 6 PM

Conclusion:

We can find out whether the date falls on the weekend or not.

 

One comment

Leave a Reply

Your email address will not be published. Required fields are marked *