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 / Date comparison throug...
Power Automate
Answered

Date comparison through Flow power automated

(0) ShareShare
ReportReport
Posted on by

Hi everyone, 

I have an issue with power automation through flow for my work Sharepoint document. 

 

I am trying to compare 2 dates (one being the due date for a project), and if this date is passed, I want to send an automated email to inform someone that the date is passed. 

I think that I have an issue with the format of my date in my column and the one that the power automation is using. Unfortunately, I could not find a solution that has already been shared in this forum.

Here is my column date used to reference the comparison:

clem6329_0-1666220297985.png

And here is my automated flow: 

clem6329_1-1666220398193.png

I would like to validate this flow and condition to be able to add second conditions in the future. 

Thanks a lot for your help.

Cheers,
Clem

Categories:
I have the same question (2)
  • Sundeep_Malik Profile Picture
    6,484 on at

    Hey @Anonymous 

     

    You will have to make both sides equal to make a comparison.

    On left side the date is 10/04/2022 12AM

    But with UtcNow() you are getting something like 10/20/2022 00:00:00Z

     

     

    So do this:

     

     

    On left side write:

     

    formatDateTime(urdatedynamicexpression, 'MM/dd/yyyy')

     

    And on right side write:

    utcNow('MM/dd/yyyy')

     

    Now the dates will be in same format.

  • Community Power Platform Member Profile Picture
    on at

    Hi @Sundeep_Malik

    Thank you for your answer. 

    I imagine you were speaking about my condition expression (left and right side). 
    So I have been able to add utcNow('MM/dd/yyyy') on the right side. But when I want to add formatDateTime(urdatedynamicexpression, 'MM/dd/yyyy') on the left side, I cannot select my dynamic expression (Date+48h). 

     

    Here is a screenshot:

    clem6329_0-1666306940271.png

    I am probably missing something. Any idea of what it would be, please?

    Thanks again,
    Clem

  • Sundeep_Malik Profile Picture
    6,484 on at

    Hey @Anonymous 

    Sometimes it happens.

     

    Do this:

     

    Add the dynamic expression without function. 

    Double click on it. The expression would be highlighted. 

    Copy it with ctrl+c shortcut.

    Remove it.

     

    After doing the above, write the formatDateTime action and paste the expression at the required position. 

    There could be some @ {} symbols, remove them and save the expression.

     

    Hope this will work.

  • Community Power Platform Member Profile Picture
    on at

    Hi @Sundeep_Malik

    Thanks for your reply. 

    It did not work, as when I was double-cliquing, nothing happened. But I found a way to get the expression by copying the condition expression to the clipboard and selecting the needed part. 
    So my expression is: 

    formatDateTime(items('Apply_to_each_2')?['Date_x002b_48h'], 'MM/dd/yyyy'). 

    I have pasted it on the left part, and on the right part, I have included the following: 
    utcNow('MM/dd/yyyy'). 
     
    On my SharePoint, I got 5 items with the dates being: 
    clem6329_0-1666374851817.png

    And when I execute my automated flow, I receive 5 emails (the result of my condition) for my 5 items, while I should receive 4 (for the red dates). 

    Do you have any idea about this issue, please? I tried to change my condition from greater to lower, and I would receive 25 emails (multiples for the date/line), which makes me think that is not the proper condition. 

    Thank you for your help,
    Clem

     

  • Community Power Platform Member Profile Picture
    on at

    Hi everybody, 

    I still have some issues with my automated flow; I would like to do a quick recap: 

    - I have a SharePoint document to keep track of my actions for different projects. Each action has a line.

    - I would like to compare 2 dates: one is a due date for an action to be done, and one is the current day's date. 

    - If the current date is past the due date, an automated email is sent to remind the person that the action needs to be done. 

     

    He is my current condition: 

    clem6329_0-1666644296153.png

    The function is: 

    formatDateTime(items('Apply_to_each_2')?['Date_x002b_48h'], 'MM/dd/yyyy')
     
    clem6329_1-1666644357293.png

    When I apply my condition, I receive an email for each line of my SharePoint (so for each action). And there is no distinction if the current date is past the due date or not. I have tried to change my condition from "is Greater than" to "is Less than" and the result is the same. 

    I have followed @Sundeep_Malik remarks but unfortunately I still have some issues. 
    Do anybody have an idea of my mistake(s)? 

    Thank you so much for your help. 

    Cheers,

    Clem

  • Community Power Platform Member Profile Picture
    on at

    Hi everyone, 

    I still have the same issue that I described in my previous answer. I tried a few things today, but nothing changed. @Sundeep_Malik, do you have an idea, please? 

     

    Also, I have added a second condition. I am using another column of my Sharepoint; if this column says "No" and the date is passed, than I want my flow to send an automatic email. But unfortunately nothing happen when both condition are applied (if I have only the date condition, an email is sent for each row of my Sharepoint document, wether the date is passed or not). 

    Here is my condition:

    clem6329_0-1666826659938.png

    Any idea? 

    Thank you for your help. 
    Best regards,

    Clem

  • Sundeep_Malik Profile Picture
    6,484 on at

    @Anonymous 

    I would have definitely helped if I could.

     

    Tagging others who might be able to help.

     

    @Expiscornovus 

    @Pstork1 

    @v-liwei-msft 

    @v-yujincui-msft 

    @v-qiaqi-msft 

  • Pstork1 Profile Picture
    68,717 Most Valuable Professional on at

    If you want to compare the output of a FormatDateTime() function with UTCNow() then you want both of them to be in ISO 8601 format.  The only time you want to use a static mask like "MM/dd/yyyy" is when you are trying to remove the time portion to see if two dates are equal to each other.  But to see if one is greater than the other you need to use a sortable version of ISO 8601.  The formatDateTime function you want will look like this. 'u' is the code for the standard ISO 8601 universal sortable DateTimeFormat. It should always be used when doing comparisons.

    formatDateTime(items('Apply_to_each_2')?['Date_x002b_48h'], 'u')

     

  • Community Power Platform Member Profile Picture
    on at

    Hi @Sundeep_Malik and @Pstork1

    @Sundeep_Malik , thank you so much for your help; I really appreciate that you tagged more people. 

    @Pstork1 , thank you for your answer. Unfortunately it did not work, I still received emails for dates that are greater than the current date. 
    I have tried multiple things: 

    - Only modify the right part of my condition, and replace the function with: formatDateTime(items('Apply_to_each_2')?['Date_x002b_48h'], 'u'). Result: No email received at all (I should have received 1 email). 

    - Modify both side, with the left side being: utcNow('u'), and the rigt side being: formatDateTime(items('Apply_to_each_2')?['Date_x002b_48h'], 'u'). Result: 3 emails received for 3 lines (I should have received only 1). 
    - Modify both side, with the left side being: utcNow(), and the rigt side being: formatDateTime(items('Apply_to_each_2')?['Date_x002b_48h'], 'u'). Result: 3 emails received for 3 lines (I should have received only 1). 
     
    clem6329_0-1666908235804.png

    And here are the dates that I compare with utcnow():

    clem6329_1-1666908420814.png

    Edit: I did a last test by removing the time in my column and I received 3 emails, when I should have received only 1.

     

    Thanks again for your help,
    Clem

  • Verified answer
    Pstork1 Profile Picture
    68,717 Most Valuable Professional on at

    UTCNow() is already in the right format.  Adding 'u' in as a parameter either won't do anything or will return a completely wrong date/time.

     

    The Left side should be just UTCNow() and the Right side should be

     

    FormatDateTime(items('Apply_to_each_2')?['Date_x002b_48h'], 'u')

    I would do some troubleshooting by adding a compose that contains both UTCNow() and the Date 48h value so you can see exactly what you are comparing.  But I've tested this using the formula I've provided and it should work.

     

     

    One other question.  Why is there another loop in the Yes side of the Condition?  Could that be why you are getting 3 emails instead of one?

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 501 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 323 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard