Working with Power Automate: Calculate 30 Days Ago

Power AutomateThis article is part of the Working with Power Automate series I am writing on my experiences working with the Power Automate, which is part of the Power Platform from Microsoft. I also have a related series of articles on Power Automate with Microsoft Dynamics 365 BC.

I was working on a flow a while ago and was using the Microsoft Dynamics 365 Business Central “Find record V3” action and needed to select invoices posted over 30 days ago. To do this I needed to calculate the date 30 days before the present date.

I did some digging and found the required function, which, somewhat counter-intuitively, is called addDays:

Expression showing the entered function to calculate 30 days ago

The function requires three parameters:

  1. timestamp – date to base the calculation on; I used the function utcNow() to get current date/time.
  2. days – the number of days to add or, if a negative number, the number of days to subtract
  3. format – format for the date, which I always use the ISO date format for as this ensures that both UK and US date systens will correctly compare (UK uses dd-MM-yyyy whereas the US uses MM-dd-yyyy).
addDays(utcNow(), -30, 'yyyy-MM-dd')

The expression returns the current date minus 30 allowing me to use this in the filter to only selected invoices older than this date.

Working with Power Automate

Working with Power Automate
What is Power Automate?
What Type of Flow Are Available?
What Type of Cloud Flows Are Available?
Power Automate with Business Central
Working with Power Automate Solutions: What Are Solutions?
Working with Power Automate Solutions: What Types of Solution Are There?
Working with Power Automate Solutions: What is a Solution Publisher?
Working with Power Automate Solutions: Create a Solution Publisher
Working with Power Automate Solutions: Create a Solution
Working with Power Automate Solutions: Publish a Solution
Working with Power Automate Solutions: Version Numbering for Solutions
Working with Power Automate Solutions: Exporting An Unmanaged Solution
Working with Power Automate Solutions: Importing An Unmanaged Solution
Working with Power Automate Solutions: Exporting A Managed Solution
Working with Power Automate Solutions: Importing A Managed Solution
Working with Power Automate Solutions: Change the Managed Properties of a Solution Component
Create a Visio Diagram of a Flow
What Are Environment Variables and Why Should They be Used?
Create an Environment Variable
Create a New Cloud Flow From a Template
Managing Large Flows
What is a Scope?
Example of How to Use a Scope
Best Practice For Using Scopes
Working with Power Automate Child Flows: What are Child Flows?
Working with Power Automate Child Flows: Create a Child Flow
Working with Power Automate Child Flows: Change Run Only Users For Child Flow
Working with Power Automate Child Flows: Add a Child Flow To a Parent Flow
Working with Power Automate Child Flows: Test the Parent/Child Flow Examples
Working with Power Automate Child Flows: Error Encountered Saving a Flow Which Calls a Child Flow
Working with Power Automate Child Flows: Error Encountered With Surprise Extra Parameters for a Child Flow
Calculate 30 Days Ago

What should we write about next?

If there is a topic which fits the typical ones of this site, which you would like to see me write about, please use the form, below, to submit your idea.

Your Name

Your Email

Suggested Topic

Suggestion Details

Leave a Reply

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