cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
charizard
Helper I
Helper I

Adding Months to Existing Date Field for Condition

I have a column in my sharepoint list called 'Loading' which is a date field and I would like to add 12 months to this column in order to create a condition. 

 

charizard_0-1654702080105.png

 

I am unable to call 'Loading' using the triggerbody function. 

My expression is: 

addToTime(triggerBody()?['Loading'],12,'Month','yyyy-MM-dd')
1 ACCEPTED SOLUTION

Accepted Solutions
charizard
Helper I
Helper I

I ended up remaking the entire flow and could pull up the columns through dynamic input. My column was 'field_4' instead of 'loading' for some reason. That was the problem.

View solution in original post

4 REPLIES 4
BCBuizer
Super User
Super User

Hi @charizard ,

 

Because you're in an "apply to each" loop, that's what you need to reference:

 

items('Apply_to_each_2')?['Loading']    

is greater than or equal to   

formatDateTime(addDays(utcNow(),-12), 'Month', 'yyyy-MM-dd')

 



Did you like my post? Please give it a thumbs up! Did I resolve your issue? Please click Accept as Solution to close the topic and so other members of the community can find solutions more easily.

Hi @BCBuizer 

I'm not sure addDays would work for what I'm doing. I need to find the date 12 months before or after 'Loading'. 

 

I've changed it to:

items('Apply_to_each_2')?['Loading']    

is greater than or equal to 

formatDateTime(addToTime(utcNow(),-12, 'Month', 'yyyy-MM-dd')) 
 
Error details:
Unable to process template language expressions for action 'Condition_2' at line '0' and column '0': 'The template language function 'greaterOrEquals' expects two parameter of matching types. The function was invoked with values of type 'Null' and 'String' that do not match.'.
BCBuizer
Super User
Super User

Hi @charizard ,

 

Indeed addDays may not be the correct function to use. What I have working for this:

 

BCBuizer_0-1654781266040.png

 

Here I found the correct use of addToTime:

 

https://tomriha.com/how-to-add-months-to-a-date-in-power-automate/

 

addToTime(utcNow(),12,'Month','yyyy-MM-dd')


Did you like my post? Please give it a thumbs up! Did I resolve your issue? Please click Accept as Solution to close the topic and so other members of the community can find solutions more easily.
charizard
Helper I
Helper I

I ended up remaking the entire flow and could pull up the columns through dynamic input. My column was 'field_4' instead of 'loading' for some reason. That was the problem.

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Users online (2,481)