Image of the contition that checks if a date is in between to dates

How to check if a date is between two dates in Power Automate

This post shows an example of how you can check if a date is less than or more than a specific date or within a time period.

A sample use case can be for instance a to check if a case must be followed up in between a time period, a start and end date. For instance when a case is created in Dynamics 365 and you have an SLA that the case must be responded to within a time period. Than you can check on the created date and a deadline for the response. If it’s overdue a notification can be sent to the service user.

How the flow works

The flow consists of thee variables startDate, endDate and currentDate. Each of the variables is set with different date values.

Step 1
In the startDate variable I use an expression that subtract 5 days from the current date to simulate a start date.

addDays(utcNow(),-5).
Image of the startDate variable in the Power Automate Flow.

Step 2
In the endDate variable I use an expression that adds 5 days from the current date to simulate an end date.

addDays(utcNow(),5)
Image of the endDate variable in the Power Automate Flow.

Step 3
In the currentDate variable I use an expression to get todays date.

utcNow()
Image of the currentDate variable in the Power Automate Flow.

Step 4

In the condition step I uses an expression that checks if currentDate is greater than startDate and less than endDate. If the expression returns true the current date is in between startDate and endDate and the condition returns true.

The flow then continues to the “if yes” step where the date variables are outputted in a compose for test purpose.

Further in the post there are examples of different results by adding and removing days to the currentDate variable as can be seen in the screenshots further down.

and(greater(variables('currentDate'),variables('startDate')),less(variables('currentDate'),variables('endDate')))
Image of the condition in the Power Automate Flow.

Example of date that is in between a time period

An example when the currentDate is in between the startDate and endDate.

Gif of the flow that has a date in between a time period

Example of date that is less than a time period

An example when the currentDate is less than startDate. By subtracting 10 days to the current date with the expression addDays(utcNow(),-10). Using addDays() expression with a negative number to get current date 10 days ago.

Gif of the flow that has a date less than a time period.

Example of date that is more than a time period

An example when the currentDate is greater than the endDate. By adding 10 days to the current date with the expression addDays(utcNow(),10).

Gif of the example when a date is more than the time period.

The complete flow

To see what expression is used in the flow check the note for each of the actions.

Image of the the example when a date is in between to dates.

Hope you find it useful!


For More Content See the Latest Posts