cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
nich3play3r
Advocate I
Advocate I

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

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!

1 ACCEPTED SOLUTION

Accepted Solutions
DamoBird365
Super User
Super User

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 😉

View solution in original post

5 REPLIES 5
DamoBird365
Super User
Super User

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 😉

View solution in original post

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.

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 😉

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

This seems to work:

 

formatDateTime(convertFromUtc(getPastTime(1,'month'),'Central Standard Time'),'MMMM yyyy')

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Top Solution Authors
Top Kudoed Authors
Users online (1,171)