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 / Set variable for previ...
Power Automate
Answered

Set variable for previous month number

(1) ShareShare
ReportReport
Posted on by 9

Hi everyone,

 

I’m new to Power Automate, and trying to create a variable in Power Automate Desktop that returns the number of the previous month, in order to fill a SAP field.

However, after testing multiple approaches, the variable always ends up not returning nothing.

Expressions that I tried:

Month(AddMonths(Today(), -1))

Month(AddToDate(Today(), 0, -1, 0))

 

I tested this by inserting this variable in the SAP field and it didn't fill nothing. I thought that it could be some problem related to SAP, so insted I tested using the "Get clipboard text" and opening a Word document, and then copying, but it also doesn't return nothing, so I think the problem must be with the variable.

 

Any help? Thanks in advance!

 

I have the same question (0)
  • Expiscornovus Profile Picture
    33,851 Most Valuable Professional on at
     
    Edit: my bad. I see this is about Power Automate Desktop. Ignore the below approach (which is for cloud flows, not desktop flows) 😅
     
    You can use the addToTime & utcNow functions for this. Use the Month interval and use the MM format (which returns only the month).
     
    Try the below:
    addToTime(utcNow(), -1, 'Month', 'MM')



     
    Happy to help out 😁

    I share more #PowerAutomate and #SharePointOnline content on my Blog, LinkedIn, Bluesky profile or Youtube Channel
  • Verified answer
    Expiscornovus Profile Picture
    33,851 Most Valuable Professional on at
     
    For Power Automate desktop try the below approach with the Add to datetime & Convert datetime to text actions.
     



     
    Happy to help out 😁

    I share more #PowerAutomate and #SharePointOnline content on my Blog, LinkedIn, Bluesky profile or Youtube Channel

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 796

#2
Valantis Profile Picture

Valantis 671

#3
Haque Profile Picture

Haque 551

Last 30 days Overall leaderboard