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 / How To Insert Variable...
Power Automate
Answered

How To Insert Variables to AddDays Expression

(0) ShareShare
ReportReport
Posted on by 18

I want to add a variable into the number of days to subtract a date from.

Current expression:

formatDateTime(addDays(utcNow(),-1), 'yyyy-MM-dd')


To-Be expression: (error: The expression is invalid)

formatDateTime(addDays(utcNow(),-variables('XDays')), 'yyyy-MM-dd')

 

Instead of a fixed "-1", I want to replace this with a variable, which I have the String and Integer format.

JeremyTan_0-1711367833135.png


May I know what is the correct expression to implement this? Thank you

Categories:
  • Verified answer
    Manish Solanki Profile Picture
    15,169 Moderator on at

    Hi @JeremyTan 

     

    Pls try the below expression:

    formatDateTime(addDays(utcNow(),mul(variables('XDays'),-1)), 'yyyy-MM-dd')

     

     

    If this helps & solves your problem, please remember to give a 👍 and accept my solution as it will help others in the future.

     

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
Mohsin Ali Profile Picture

Mohsin Ali 424

#2
11manish Profile Picture

11manish 328 Super User 2026 Season 2

#3
M Bilal Khan Profile Picture

M Bilal Khan 274

Last 30 days Overall leaderboard