Skip to main content

Notifications

Community site session details

Community site session details

Session Id : twfxzNd+FPD4lg266GAQYU
Power Automate - Power Automate Desktop
Answered

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

Like (1) ShareShare
ReportReport
Posted on 19 Jun 2025 04:53:37 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 19 Jun 2025 at 07:34:01
    "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 19 Jun 2025 at 07:31:08
    "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,451 Super User 2025 Season 1 on 19 Jun 2025 at 06:59:59
    "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,639 Super User 2025 Season 1 on 19 Jun 2025 at 06:58:36
    "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

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June 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 497 Super User 2025 Season 1

#2
David_MA Profile Picture

David_MA 436 Super User 2025 Season 1

#3
Riyaz_riz11 Profile Picture

Riyaz_riz11 244 Super User 2025 Season 1

Loading started