Skip to content

Instantly share code, notes, and snippets.

@dbiesecke
Last active December 19, 2023 13:40
Show Gist options
  • Save dbiesecke/20684b25d6c811c60f51da9f5f6cef01 to your computer and use it in GitHub Desktop.
Save dbiesecke/20684b25d6c811c60f51da9f5f6cef01 to your computer and use it in GitHub Desktop.
PowerAutomate / Logical Apps - Conditions - example only match specific time

PowerAutomate Conditions

If / else

if(equals({variable},'value'),'It matches','It doesn't match')
if(
    or(
        equals(triggerBody()['text'],'value')
    ,
        and(
            greater(triggerBody()['number'],10)
        ,
            contains(triggerBody()['text_1'],'Test Phrase')         
        )
    )
,
    true
,
    false
)

Example Netesd Conditions

@and(
   contains(triggerOutputs()?['body/Name'], '.pdf'), 
   and(
      greater(triggerOutputs()?['body/Size'], 102400), 
      less(triggerOutputs()?['body/Size'], 1048576)
    )
)

DayOfWeek

Mondays to Fridays, which corresponds to integers 1 to 5

0 if the date is a Sunday 1 if the date is a Monday 2 if the date is a Tuesday 3 if the date is a Wednesday 4 if the date is a Thursday 5 if the date is a Friday 6 if the date is a Saturday

dayOfWeek(utcnow())

equals(dayOfWeek(utcNow()),1)

How to Check if a Date is on a Business Day in Power Automate - Power Tech Tips

Trigger Condition

  • Use formatdate / dayOfWeek & lessOrEquals / GreaterOrequals to check for specific timeframe
  • Set the condition in your specific trigger

lessOrEquals( formatdatetime(utcNow(),'HH:mm'), formatdatetime('9:00','HH:mm'))

GreaterOrequals( formatdatetime(utcNow(),'HH:mm'), formatdatetime('16:00','HH:mm'))

// Match only Workdays between between 09:00 - 16:00
// Keep in mind thats UTC Time!
@and(
     and(
	   GreaterOrequals(dayOfWeek(utcNow()),1),
	   lessOrEquals(dayOfWeek(utcNow()),5)
     ),
     GreaterOrequals(     
       formatdatetime(utcNow(),'HH:mm'),
       formatdatetime('08:00','HH:mm')
     ),
     lessOrEquals(
       formatdatetime(utcNow(),'HH:mm'),
       formatdatetime('17:00','HH:mm')
     )
)

// Match only Workdays between between 16:00 - 09:00 & Sa/So 00:00 - 23:59 UTC
// Keep in mind thats UTC Time!
@or(
   and( 
	   GreaterOrequals(dayOfWeek(utcNow()),1),
	   lessOrEquals(dayOfWeek(utcNow()),5),
	   and( 
	     lessOrEquals(     
	       formatdatetime(utcNow(),'HH:mm'),
	       formatdatetime('08:00','HH:mm')
	     ),
	     GreaterOrequals(
	       formatdatetime(utcNow(),'HH:mm'),
	       formatdatetime('17:00','HH:mm')
	     ) 
      )  
   ),
   and( 
	   GreaterOrequals(dayOfWeek(utcNow()),6),
	   lessOrEquals(dayOfWeek(utcNow()),0)  
   )
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment