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

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Comparing dates withou...
Power Automate
Unanswered

Comparing dates without year

(0) ShareShare
ReportReport
Posted on by 2

Hello,

 

I have a problem with comparing dates without year. The flow is for a birthday list:

When a employee his birthday is within now and 28 days, i want to update the employees column 'JarigDatum' to the integer 1.

Otherwise the integer has to be 0. The flow works but it dont gives the right employees to 1.  

 

https://imgur.com/27O74uJ

 

The first condition is:
@lessOrEquals(formatDateTime(items('Op_elk(e)_toepassen_3')?['JarigDatum'], 'MM/dd'), formatDateTime(utcNow(), 'MM/dd'))

the second is:

@greaterOrEquals(formatDateTime(addDays(items('Op_elk(e)_toepassen_3')?['JarigDatum'], -28), 'MM/dd'), formatDateTime(utcNow(), 'MM/dd'))

 

Maybe someone have ideas what i'm doing wrong?

Categories:
I have the same question (0)
  • PieterVeenstra Profile Picture
    on at
    Re: Comparing dates without year

    Hi @msflow,

     

    When things become complicate with expressions and conditions I would use variables. That way you can use the run history to debug your flow.

     

    Use the Initialize Varibale action to create variable and then store your birth date in there and the 28 days away date in a separate variable.

     

    Then your condition becomes a simple comparison of dates.

  • msflow Profile Picture
    2 on at
    Re: Comparing dates without year

    Hi @Pieter_Veenstra

     

    I can't do the action 'Initialize Variable' in a for each loop. I can intialize it before the For-Each loop but then i got 1 variable with all birh-dates of all employees. 

     

  • PieterVeenstra Profile Picture
    13 on at
    Re: Comparing dates without year

    Iniitialize a varible at the top of your Flow of the type that you need inside  the For Each but leave the value empty.

     

    Then inside your for each you can use the Set Variable actions to set the variable to the value

  • Verified answer
    v-xida-msft Profile Picture
    on at
    Re: Comparing dates without year

    Hi @msflow,

     

    Could you please show a bit more about the 'JarigDatum' column that you mentioned?

    Could you please show more details about your SharePoint list?

    Further, do you want to update the employees whose birthday is between utcnow() and utcnow()+28 days?

     

    I suppose that you want to update the employees whose birthday is between utcnow() and utcnow()+28 days, is it true? I think there is something wrong with the formula that you provided within Condition box.

     

    I have created a SharePoint list on my side and the data structure of it as below:2.JPG

    Note: The Birth Date column is a Date type column, the JarigDatum column is Number type column and the default value of it is empty.

     

    If you want to update the employees whose birthday is between utcnow() and utcnow()+28 days, I afraid that there is something wrong with the formula that you provided within your Condition box. 

     

    I have made a test on my side and please take a try with the following workaround:

    • Add a Recurrence trigger, Interval set to 1 and Frequency set to Day.
    • Add a "Get items" action, specify Site Address and List Name.
    • Add a "Apply to each", input parameter set to output of "Get items" action.
    • Within "Apply to each" action, add a Condition, click "Edit in advanced mode", type the following formula:

     

    @and(greaterOrEquals(formatDateTime(items('Apply_to_each')?['Birth_x0020_Date'], 'MM/dd'), utcNow('MM/dd')),lessOrEquals(formatDateTime(items('Apply_to_each')?['Birth_x0020_Date'], 'MM/dd'), formatDateTime(addDays(utcNow(), 28), 'MM/dd')))

     

     

    • Within "If/yes" branch of Condition, add a "Update item" action, specify Site Address and List Name. Id field set to ID dynamic content of "Get items" action. The JarigDatum field set to 1.
    • Within "If/no" branch of Condition, add a "Update item 2" action, specify Site Address and List Name. Id field set to ID dynamic content of "Get items" action. The JarigDatum field set to 0.

    Image reference:3.JPG

     

    The flow works successfully as below:4.JPG

     

    5.JPG

     

    In addition, you could also consider take a try to add two Conditions within your flow as below:

     

    6.JPG

     

    Within Condition box, click "Edit in advanced mode", type the following formula:

    @greaterOrEquals(formatDateTime(items('Apply_to_each')?['Birth_x0020_Date'], 'MM/dd'), utcNow('MM/dd'))

    Within Condition 2 box, click "Edit in advanced mode", type the following formula:

    @lessOrEquals(formatDateTime(items('Apply_to_each')?['Birth_x0020_Date'], 'MM/dd'), formatDateTime(addDays(utcNow(), 28), 'MM/dd'))

     

     

    Best regards,

    Kris 

     

     

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
Tomac Profile Picture

Tomac 497 Moderator

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 477 Super User 2025 Season 2

#3
chiaraalina Profile Picture

chiaraalina 242

Last 30 days Overall leaderboard