web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Adding Days Microsoft ...
Power Automate
Answered

Adding Days Microsoft Forms

(0) ShareShare
ReportReport
Posted on by 261

I have a Microsoft From with a numeric field (entry is limited to single digit) I am trying to add this numeric field to a date but I run in an error

 

nvalidTemplate. Unable to process template language expressions in action 'Create_item' inputs at line '1' and column '34836': 'The template language function 'addDays' expects its second parameter to be an integer. The provided value is of type 'String'. Please see https://aka.ms/logicexpressions#adddays for usage details.'.

 

the expression I am using is 

 

addDays(outputs('Get_response_details')?['body/rb3f1f25faf5241b7ab7e3004eb2c809a'],outputs('Get_response_details')?['body/rae71681f172f4b618d046dee3a781420'],'yyyy-MM-dd')

 

Any ideas?

Thanks

Categories:
I have the same question (0)
  • Verified answer
    abm abm Profile Picture
    32,865 Most Valuable Professional on at

    Hi @mtagliaferri 

     

    Try the below.

     

    addDays(outputs('Get_response_details')?['body/rb3f1f25faf5241b7ab7e3004eb2c809a'],int(outputs('Get_response_details')?['body/rae71681f172f4b618d046dee3a781420']),'yyyy-MM-dd')

  • mtagliaferri Profile Picture
    261 on at

    Hi @abm 

    Thanks that took care f the problem,

     

    I just realised that the calculation does not return the intended result, this is because the form asks the user how any days are required from the start date so I have a StartDate and NDays if the user needs 1 day then if the StartDate is 04/11/2021 the End Date will be the same date 04/11/2021

    I though editing an placing a -1 in the expression to always detract 1 day to the calculation which then will return the correct result

    addDays(outputs('Get_response_details')?['body/rb3f1f25faf5241b7ab7e3004eb2c809a'],int(outputs('Get_response_details')?['body/rae71681f172f4b618d046dee3a781420']-1),'yyyy-MM-dd')

    But that is sending back to square 1 as the expression is invalid.

     

    I have considered two date Fields in the form but I am trying to simplify it as much as possible and I would like to keen the TotDays field

     

  • mtagliaferri Profile Picture
    261 on at

    Hi @abm 

    I have solved the issue by initialising a variable set to:

    Then I got the calculation using the variable:

    addDays(variables('DateCalculated'),int(outputs('Get_response_details')?['body/rae71681f172f4b618d046dee3a781420']),'yyyy-MM-dd')

    This works, but if you have alternatives I am happy to learn 🙂

     

    Thanks for the help.

  • abm abm Profile Picture
    32,865 Most Valuable Professional on at

    Hi @mtagliaferri 

     

    My answer was based on your reported issue. In Microsoft Forms you have declared and restricted to numbers but in Power Automate when you get that response and if you doing any calculations you need to convert to int().

     

    int(outputs('Get_response_details')?['body/rae71681f172f4b618d046dee3a781420'])

     

    You error reported was 

     function 'addDays' expects its second parameter to be an integer.

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 503 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 321 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard