Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Power Automate Desktop
Answered

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

(1) ShareShare
ReportReport
Posted on by 6

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.

Categories:
  • 美近-19060449-0 Profile Picture
    6 on at
    "SubtractDate must be Datetime" error in Power Automate Desktop when using datetime variable
     
    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!
  • 美近-19060449-0 Profile Picture
    6 on at
    "SubtractDate must be Datetime" error in Power Automate Desktop when using datetime variable
     

    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!

     
  • Verified answer
    VishnuReddy1997 Profile Picture
    2,423 Super User 2025 Season 1 on at
    "SubtractDate must be Datetime" error in Power Automate Desktop when using datetime variable
     
    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
  • Suggested answer
    eetuRobo Profile Picture
    3,587 Super User 2025 Season 1 on at
    "SubtractDate must be Datetime" error in Power Automate Desktop when using datetime variable
    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

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

Michael Gernaey – Community Spotlight

We are honored to recognize Michael Gernaey as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 566 Super User 2025 Season 1

#2
David_MA Profile Picture

David_MA 516 Super User 2025 Season 1

#3
stampcoin Profile Picture

stampcoin 492