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 / Filter Array condition...
Power Automate
Answered

Filter Array condition giving random dates

(0) ShareShare
ReportReport
Posted on by 20

Hello,

 

I am trying to return dates from a .csv where the records "Completion Date" is within the last 7 days.

 

In basic mode:

Scribbler_0-1716313687051.png

 

In advanced mode to show code:

Scribbler_1-1716313724016.png

 

I am receiving records with dates reaching back all the way to earliest is March 1st, 2022 and the most recent being May 15th, 2024.

 

Is there a better expression or condition I can be using here to receive only dates within the last 7 days?

 

The format I am using is dd-MM-yyyy.

 

I didn't think it was required to mention, but ff any more information is needed to advise, I can provide further details of all the previous operations that lead to this filter array. 

Categories:
I have the same question (0)
  • VictorIvanidze Profile Picture
    13,073 on at

    Format both dates to yyyyMMdd.

  • Scribbler Profile Picture
    20 on at

    The .csv file contains the date in this exact format:

     

    01-Mar-2022 12:19 PM America/New York

     

    Here is a quick overview of the flow:

    Scribbler_1-1716315977060.png

     

    In the Apply to Each, there is a CreateJSON where I change the date format to 'dd-MM-yyyy':

    Scribbler_2-1716316081013.png

    formatDateTime(first(split(outputs('DefineRecordItems')?[18], 'America/New York')), 'dd-MM-yyyy')

     

    Here I removed the 'America/NewYork' with split and specify the date format to 'dd-MM-yyyy'

     

    I had tried your suggestion before replying back, and changed the format in both this step here, as well as the addDays expression within the filter array below to yyyyMMdd, but received no outputs in the filter array:

     

    Format showing in CreateJSON:

    Scribbler_4-1716316585202.png

     

    No outputs:

    Scribbler_5-1716316616082.png


    Hope I am not too spotty in my explanation of the workflow, thought to mention only the operations I am handling the dates.

     

     

     

     

     

     

     

  • VictorIvanidze Profile Picture
    13,073 on at

    Did you change the expression in the Filter array action?

  • Scribbler Profile Picture
    20 on at

    Yes, to the format you suggested, yyyyMMdd. First test I changed it in the Filter Array and in the CreateJSON for Completion Date where I showed the code snippet above with the formatDateTime. I received no outputs as I showed in the previous post.

     

    I just tested again. This time I changed my date format in the CreateJSON for the Completion Date back to the format I had before, and changed only the Filter array to your suggested date format. 

     

    I'm still seeing dates from 2022, and not within 7 days ago.

  • Verified answer
    Scribbler Profile Picture
    20 on at

    I was able to successfully filter the dates to receive all items for Completion Date within the last 7 days with your suggested date format. I used the format "yyyy-MM-dd" in the Filter Array as well as in the CreateJSON operation:

     

    CreateJSON:

    formatDateTime(first(split(outputs('DefineRecordItems')?[18], 'America/New York')), 'yyyy-MM-dd')

     

    Filter Array:

    addDays(utcNow(), -7, 'yyyy-MM-dd')

     

    Thank you for your help!

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

#2
Tomac Profile Picture

Tomac 321 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard