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 / How to get Last Month ...
Power Automate
Answered

How to get Last Month Start date and Last Month End Date 01.06.2023 & 30.06.2023 formate in Power automate desktop flow ?

(0) ShareShare
ReportReport
Posted on by 203

Hi Everyone,

 

How to get Last Month Start date and Last Month End Date 01.06.2023 & 30.06.2023 format in Power automate desktop flow please help me ?

I have the same question (0)
  • Verified answer
    Agnius Bartninkas Profile Picture
    Most Valuable Professional on at

    Like this:

    Agnius_1-1689165271001.png

    Here's a snippet you can also copy and paste directly into PAD to have all of those actions created for you:

    DateTime.GetCurrentDateTime.Local DateTimeFormat: DateTime.DateTimeFormat.DateAndTime CurrentDateTime=> CurrentDateTime
    DateTime.Add DateTime: CurrentDateTime TimeToAdd: $'''-%CurrentDateTime.Day%''' TimeUnit: DateTime.TimeUnit.Days ResultedDate=> EndOfLastMonth
    DateTime.Add DateTime: EndOfLastMonth TimeToAdd: $'''-%EndOfLastMonth.Day - 1%''' TimeUnit: DateTime.TimeUnit.Days ResultedDate=> StartOfLastMonth
    Text.ConvertDateTimeToText.FromCustomDateTime DateTime: EndOfLastMonth CustomFormat: $'''dd.MM.yyyy''' Result=> EndOfLastMonthAsText
    Text.ConvertDateTimeToText.FromCustomDateTime DateTime: StartOfLastMonth CustomFormat: $'''dd.MM.yyyy''' Result=> StartOfLastMonthAsText
    SET DateRange TO $'''%StartOfLastMonthAsText% & %EndOfLastMonthAsText%'''

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

    If you are interested in Power Automate, you might want to follow me on LinkedIn at https://www.linkedin.com/in/agnius-bartninkas/

  • Ahmedmuz Profile Picture
    203 on at

    It's Not getting the exact date of Previous month like 01.06.2023 its actually showing the 30 days minus please help here 

  • Chriddle Profile Picture
    8,697 Super User 2026 Season 1 on at

    Compose action with

     

    Last month start: @{getPastTime(1, 'Month', '01.MM.yyyy')}
    Last month end: @{addDays(utcNow('yyyy-MM-01'), -1, 'dd.MM.yyyy')}

     

     

    Output:

    Last month start: 01.06.2023
    Last month end: 30.06.2023

     

    Don't use data with such a date format to do calculations or store them in Sharepoint lists etc. 😉

  • Agnius Bartninkas Profile Picture
    Most Valuable Professional on at

    Wrong forum, mate. This is a Power Automate Desktop question 😅

  • Agnius Bartninkas Profile Picture
    Most Valuable Professional on at

    Can you please share a screenshot of your flow and the output?

  • Chriddle Profile Picture
    8,697 Super User 2026 Season 1 on at

    Ups

  • Ahmedmuz Profile Picture
    203 on at

    Hi Agnius,

     

    Its working thanks, But if you could help in explaining a little bit how its working it a great help will be as well please.  

  • Verified answer
    Agnius Bartninkas Profile Picture
    Most Valuable Professional on at

    The Get current date time action retrieves the current date and stores it in a date time variable called %CurrentDateTime%.

     

    A variable of type date time has a property called .Day which is a numeric value of the day of the month. So, if the %CurrentDateTime% is the 13th of July 2023, %CurrentDateTime.Day% will be equal to 13.

     

    The Add to date time action allows adding numeric values of various intervals to a date variable. Adding -%CurrentDateTime.Day% days to %CurrentDateTime% will always result in the last day of the previous month. You are effectively deducting (because of the minus) 13 days from the 13th of July, so that will result in the 30th of June.

     

    We then store that in a different variable (such as %EndOfLastMonth%) and use that variable again in another Add to date time action. We use the same operation, but deduct 1 less day, so that we end up with the first of the month, instead of the last of the month before last month. So, adding -%EndOfLastMonth.Day-1% (note the -1 there) days to %EndOfLastMonth% will effectively deduct 29 days from the 30th of June, resulting in the 1st of June.

     

    This is a standard flow that will always work, regardless of the month in question and regardless of the current date.

     

    The last steps are just formatting the two dates in a specific format that you requested and putting them into a single string separated by an ampersand.

    -------------------------------------------------------------------------

    If I have answered your question, please mark it as the preferred solution.

    If you like my response, please give it a Thumbs Up.

    If you are interested in Power Automate, you might want to follow me on LinkedIn at https://www.linkedin.com/in/agnius-bartninkas/

     

  • Ahmedmuz Profile Picture
    203 on at

    Thanks a lot for explanations 🙂 
    Can you also please help me how to create a pivot table using the Power automate desktop flow and its features please ...?

     

  • Verified answer
    Agnius Bartninkas Profile Picture
    Most Valuable Professional on at

    If my reply answers your question, please give it a thumbs up and mark it as the solution to the topic. This helps me establish myself as an active member of the community, as well as points other people who may be facing a similar issue to an actually working solution.

     

    I noticed the other topic about Pivot tables. I will reply there, as this is a completely different topic.

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 April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 632

#2
Haque Profile Picture

Haque 458

#3
Valantis Profile Picture

Valantis 357

Last 30 days Overall leaderboard