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 / Having issues with com...
Power Automate
Answered

Having issues with comparing conditionals within an apply to each statement

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

 Hi, i'm new to Microsoft Flow and have created one automation already. I'm pulling from a sharepoint list that compares new hire dates with current dates. I'm then taking that new date and subtracting the year. I'm having issues figuring out how to do the subtract statement. I already have the comparision done and working. Adding the new subtraction variable can only happen in the top level. When I try to create the (StartDate) variable it will create a new apply to each which also fails. I only need to compare the years (2021 to 1998). Any help would be appreciated

oles11aaron_0-1634925473786.png

oles11aaron_1-1634925551595.png

oles11aaron_2-1634925590708.png

 

I'm currently getting an error message that ticks translates to a string, do I have to convert to integer to get it to work correctly?

oles11aaron_3-1634925672811.png

 

Any help or information would be greatly appreciated. 

 

Categories:
  • Verified answer
    Community Power Platform Member Profile Picture
    Microsoft Employee on at

    I found a solution to this by converting the utcnow date and time (string) to int and doing the subtrahend then. The code looks like: 

    sub(int(utcnow('yyyy')), int(formatdatetime(item()?['StartDate'], 'yyyy')))
    I just needed to compare the years but if someone wants to compare the days or months they would change the 'yyyy' to 'dd' or 'mm'. 

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 389

#2
11manish Profile Picture

11manish 345 Super User 2026 Season 2

#3
M Bilal Khan Profile Picture

M Bilal Khan 308

Last 30 days Overall leaderboard