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 / Get previous year if t...
Power Automate
Answered

Get previous year if the month is January

(0) ShareShare
ReportReport
Posted on by 90

Hi,

 

I have a flow that is scheduled to run each month and then it creates an email that includes a link to a sharepoint folder, however this process works a month behind so for January 2023, the email needs to say 2022_12 instead of 2023_01.

 

I am able to get the prior month but am having trouble getting the previous year if the current month is January.

Categories:
  • Verified answer
    Sundeep_Malik Profile Picture
    6,501 on at

    Hey @la09 

     

    Built a test scenario for you:

     

    This is how the whole flow looks like:

    Sundeep_Malik_2-1672916389481.png

     

     

    Today's Date:

    Sundeep_Malik_0-1672916291312.png

     

    Expression: 

    utcNow('dd/MM/yyyy')
     
    Month Variable:
    Sundeep_Malik_1-1672916339840.png

     

    Expression:

    int(utcNow('MM'))
     
    Year:
     
     Sundeep_Malik_3-1672916414244.png

     

    Expression:

    int(if(equals(variables('Month'),1),sub(int(utcNow('yyyy')),1),utcNow('yyyy')))
     
    Previous Month:
     
    Sundeep_Malik_4-1672916447292.png

    Expression:

    if(equals(variables('Month'),1),12,sub(variables('Month'),1))
     
    Final Result:
     
    Sundeep_Malik_5-1672916482515.png

     

    Sundeep_Malik_6-1672916499048.png

     

    Sundeep_Malik_7-1672916512062.png

     

    Sundeep_Malik_8-1672916525902.png

     

    I hope this helps 🙂

     
  • Hardesh15 Profile Picture
    7,087 Super User 2024 Season 1 on at

    @la09 As this is your scheduled flow running each month. Take the date of your scheduled and use Adddays(). 

    For example- Adddays(utcnow(),-13,'yyyy'). use second argument as per your scheduled flow.

    Please 'Thumbs Up' the posts that helped you and 'Accept as Solution' if my post answered your question.

    @Hardesh /Gopenly.in

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Automate

#1
11manish Profile Picture

11manish 302 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 263

#3
Henil Profile Picture

Henil 115

Last 30 days Overall leaderboard