Skip to main content

Notifications

Community site session details

Community site session details

Session Id : 0wkVIHs2r68ogM2Eigc4xq
Power Automate - Building Flows
Answered

Date comparison through Flow power automated

Like (0) ShareShare
ReportReport
Posted on 19 Oct 2022 23:03:20 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

  • Community Power Platform Member Profile Picture
    on 28 Oct 2022 at 21:01:41
    Re: Date comparison through Flow power automated

    Hi @Pstork1 , 

    Thank you so much for your help. You were right; it works. My issue was that I did call out to send an email to each item if my condition was 'Yes'. I changed it to have 'send email' only, and it works. 

    I have added as well my second condition, and everything works fine. 
    Thank you so much for your precious help. 
    Have a good weekend,
    Clem

  • Verified answer
    Pstork1 Profile Picture
    66,174 Most Valuable Professional on 28 Oct 2022 at 02:57:43
    Re: Date comparison through Flow power automated

    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?

  • Community Power Platform Member Profile Picture
    on 27 Oct 2022 at 22:04:53
    Re: Date comparison through Flow power automated

    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

  • Pstork1 Profile Picture
    66,174 Most Valuable Professional on 27 Oct 2022 at 03:48:18
    Re: Date comparison through Flow power automated

    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')

     

  • Sundeep_Malik Profile Picture
    6,480 on 27 Oct 2022 at 03:07:06
    Re: Date comparison through Flow power automated

    @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 

  • Community Power Platform Member Profile Picture
    on 26 Oct 2022 at 23:25:24
    Re: Date comparison through Flow power automated

    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

  • Community Power Platform Member Profile Picture
    on 24 Oct 2022 at 20:52:34
    Re: Date comparison through Flow power automated

    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 21 Oct 2022 at 18:01:06
    Re: Date comparison through Flow power automated

    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

     

  • Sundeep_Malik Profile Picture
    6,480 on 21 Oct 2022 at 02:54:39
    Re: Date comparison through Flow power automated

    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 20 Oct 2022 at 23:03:54
    Re: Date comparison through Flow power automated

    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

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Power Automate - Building Flows

#1
stampcoin Profile Picture

stampcoin 97

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 70 Super User 2025 Season 1

#3
David_MA Profile Picture

David_MA 48 Super User 2025 Season 1

Overall leaderboard