web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Calculating Specific D...
Power Automate
Unanswered

Calculating Specific Date Ranges in Power Automate Desktop

(0) ShareShare
ReportReport
Posted on by

 

Hello everyone,

 

I am trying to set specific date ranges in Power Automate Desktop based on the current date. Specifically, I want to:

 

  1. Set inicio1 to the start date of the previous month.
  2. Set fim1 to the end date of the previous month.
  3. Set inicio2 to the start date of the current month.
  4. Set fim2 to the current date.

In other platforms, I would typically use the following logic:

 

SET inicio1 TO formatDateTime(startOfMonth(addMonths(utcNow(), -1)), 'dd/MM/yyyy')
SET fim1 TO formatDateTime(endOfMonth(addMonths(utcNow(), -1)), 'dd/MM/yyyy')
SET inicio2 TO formatDateTime(startOfMonth(utcNow()), 'dd/MM/yyyy')
SET fim2 TO formatDateTime(utcNow(), 'dd/MM/yyyy')
 

However, I am having difficulty implementing this in Power Automate Desktop. Could someone guide me on how to achieve this or provide an alternative solution?

 

Thank you in advance for your assistance!

I have the same question (0)
  • davidengel Profile Picture
    6 on at

    Power Automate Desktop has several actions related to datetime and formatting the output. "Get current date and time" is the starting point, and returns your fim2 before formatting. "Add to datetime" can be used with positive and negative values of multiple time units (seconds, hours, days, months, etc.). "Convert datetime to text" takes care of all of the formatting needs.

  • Agnius Bartninkas Profile Picture
    Most Valuable Professional on at

    The following flow will do it for you:

    Agnius_0-1692764980815.png

     

    The idea is using Get current date and time to get the current date, then using Add to datetime to do the calculations and Convert datetime to text to convert it to the format you want.

    Every datetime variable has a property called .Day that contains the day of the month as an integer. So, this is what is normally used to get the first or the last day of the current or the previous month.

     

    Here's a snippet you can copy and paste to PAD to get those actions created for you:

    DateTime.GetCurrentDateTime.Local DateTimeFormat: DateTime.DateTimeFormat.DateAndTime CurrentDateTime=> CurrentDateTime
    DateTime.Add DateTime: CurrentDateTime TimeToAdd: $'''-%CurrentDateTime.Day - 1%''' TimeUnit: DateTime.TimeUnit.Days ResultedDate=> inicio2
    DateTime.Add DateTime: CurrentDateTime TimeToAdd: $'''-%CurrentDateTime.Day%''' TimeUnit: DateTime.TimeUnit.Days ResultedDate=> fim1
    DateTime.Add DateTime: fim1 TimeToAdd: $'''-%fim1.Day - 1%''' TimeUnit: DateTime.TimeUnit.Days ResultedDate=> inicio1
    Text.ConvertDateTimeToText.FromCustomDateTime DateTime: CurrentDateTime CustomFormat: $'''dd/MM/yyyy''' Result=> fim2
    Text.ConvertDateTimeToText.FromCustomDateTime DateTime: inicio2 CustomFormat: $'''dd/MM/yyyy''' Result=> inicio2
    Text.ConvertDateTimeToText.FromCustomDateTime DateTime: fim1 CustomFormat: $'''dd/MM/yyyy''' Result=> fim1
    Text.ConvertDateTimeToText.FromCustomDateTime DateTime: inicio1 CustomFormat: $'''dd/MM/yyyy''' Result=> inicio1
    

    -------------------------------------------------------------------------
    If I have answered your question, please mark it as the preferred solution. If you like my response, please give it a Thumbs Up.

    I also provide paid consultancy and development services using Power Automate. If you're interested, DM me and we can discuss it.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 605

#2
Valantis Profile Picture

Valantis 340

#3
11manish Profile Picture

11manish 284

Last 30 days Overall leaderboard