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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Derive month and year ...
Power Automate
Answered

Derive month and year of last day of prior month in filename

(0) ShareShare
ReportReport
Posted on by 249

Hi.

 

New to Power Automate and have a Power BI PDF export to SharePoint cloud flow I'm working on. Last bit I can't seem to overcome is getting the year and month values for the prior month in a function for the file name. So, I'm after:

 

Goal progress as of [month name of prior month], [year of last day of prior month].pdf

 

I can get the month with getPastTime(1,'month','MMMM'), but I'm having trouble working out how to get the YYYY value from the last day of the prior month.

 

Thanks a lot for any pushes you can give!

Categories:
I have the same question (0)
  • Verified answer
    DamoBird365 Profile Picture
    8,942 Microsoft Employee on at

    Hi @nich3play3r 

     

    Are you just looking for getPastTime(1,'month','MMMM yyyy')?

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
    Cheers,
    Damien


    P.S. take a look at my new blog here and like & subscribe to my YouTube Channel thanks 😉

  • nich3play3r Profile Picture
    249 on at

    Yes, apparently. 😖  My date format was including hyphens, which it seems was my undoing. Thanks very much, @DamoBird365 . Really appreciate you taking the time to answer here.

  • DamoBird365 Profile Picture
    8,942 Microsoft Employee on at

    Hi @nich3play3r 

     

    No probs.  Forgot to mention I did a post on date string manipulation here https://www.damobird365.com/formatdatetime-and-formatting-a-string-date/

     

    If you want a hyphen you could just combine two expressions.

     

    Goal progress as of @{getPastTime(1,'month','MMMM')}-@{getPastTime(1,'month','yyyy')}.pdf

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
    Cheers,
    Damien


    P.S. take a look at my new blog here and like & subscribe to my YouTube Channel thanks 😉

  • nich3play3r Profile Picture
    249 on at

    So, I know getpasttime is running off UTC. If I run my flow at 10:30 pm US central time, with the code mentioned above, the value is June 2021, even though I'm still in June 2021 as I write this. Do I need to insert a step to get an adjusted version of the UTC date value for my location, or can that be incorporated in my existing function?

     

    Thanks

  • nich3play3r Profile Picture
    249 on at

    This seems to work:

     

    formatDateTime(convertFromUtc(getPastTime(1,'month'),'Central Standard Time'),'MMMM yyyy')
  • hasrulhashim Profile Picture
    4 on at

    how to get result 28 February 2022 instead of February 2022

     

    Current formula : 

    getPastTime(1,'Month','MMMM yyyy') :  February 2022
  • nich3play3r Profile Picture
    249 on at

    Have you read through @DamoBird365 's very nice post here?

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 503 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 321 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard