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 / "SubtractDate must be ...
Power Automate
Answered

"SubtractDate must be Datetime" error in Power Automate Desktop when using datetime variable

(1) ShareShare
ReportReport
Posted on by 9

I am creating a flow in Power Automate Desktop (version 2.57.184.25154) to retrieve the datetime one month prior to the current date.

 

For example:

If the current month is 202506, I want to get 202505.

 

I used the "Get current date and time" action to generate a datetime-type variable,

and passed it to the "Subtract dates" action.

However, the following error is displayed:

 
 

Error message:

The argument 'SubtractDate' must be of type 'Datetime'.

 
 

The variable is recognized as a Datetime value, and I believe its type is correct.

 

I have tried:

 

  •  

    Renaming the variable


  •  

    Restarting Power Automate Desktop


  •  

    Reinstalling the application



  •  
 

But the same error continues to occur.

 

Below is the structure of the flow:

 

  1.  

    Get current date and time%現在日時_raw%


  2.  

    Subtract dates%現在日時_raw% minus 31 days → %前月日時%



  3.  
 

I would appreciate it if you could provide any possible causes or similar known issues.

I have the same question (0)
  • Suggested answer
    eetuRobo Profile Picture
    4,484 Super User 2026 Season 1 on at
    Subtract dates -action expects two dates. 


    I assume you are giving it one date (From date) and number of days to substract (Subtract date) which seems to be -31 in your flow:

    Use "Add to datetime" -action instead. Even though the actions says "Add to datetime" you can substract by giving negative number to the "Add" -field
  • Verified answer
    VishnuReddy1997 Profile Picture
    2,656 Super User 2026 Season 1 on at
     
    Please find the solution. Please copy the below code to your flow.
     
     
    Code:
    DateTime.GetCurrentDateTime.Local DateTimeFormat: DateTime.DateTimeFormat.DateAndTime CurrentDateTime=> CurrentDateTime
    DateTime.Add DateTime: CurrentDateTime TimeToAdd: -1 TimeUnit: DateTime.TimeUnit.Months ResultedDate=> ResultedDate
    Text.ConvertDateTimeToText.FromCustomDateTime DateTime: ResultedDate CustomFormat: $'''yyyyMM''' Result=> FormattedDateTime
    
     
    (Note:- if you got your solution you can mark as solution and gives kudos)
     
    Thanks & Regards
    Vishnu Reddy
  • 美近-19060449-0 Profile Picture
    9 on at
     

    Thank you so much! Your explanation and sample flow worked perfectly. I was stuck for days, but now it's finally working thanks to you. Really appreciate it!

     
  • 美近-19060449-0 Profile Picture
    9 on at
     
    Now I understand that I should have used the "Add to datetime" action in this case.  
    The issue is resolved. Thank you so much for your clear and helpful response!

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

These are the community rock stars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 592

#2
Valantis Profile Picture

Valantis 340

#3
11manish Profile Picture

11manish 284

Last 30 days Overall leaderboard