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 based on ...
Power Automate
Answered

Filter array based on dates, with expression

(4) ShareShare
ReportReport
Posted on by 34
Hello
 
I have a list of dates and names generated from the get items action in excel online.
The dates are in ISO8601 format.
 
This is an example of an item in the array:
 
I want to retrieve everything of the next month and i use this formula in the filter array action:
 
@equals(formatDateTime(item()['Datum'], 'MM'), addDays(utcNow(), 15, 'MM'))
 
(I add 15 days to get to the next month as this flow runs always on the 25th).
 
 
I get this error:
The execution of template action 'Filter_array' failed: The evaluation of 'query' action 'where' expression '@equals(formatDateTime(item()['Datum'], 'MM'), addDays(utcNow(), 15, 'MM'))' failed: 'In function 'formatDateTime', the value provided for date time string '' was not valid. The datetime string must match ISO 8601 format.'.
 
I presume there is a problem with the item()['Datum'] in the formula?
 
Thanks for any help
 
Neil
Categories:
I have the same question (0)
  • Suggested answer
    trice602 Profile Picture
    15,404 Super User 2025 Season 2 on at
    Hi,
     
    Yes the issue is with formatDateTime().  Modify both to this format, 'yyyy-MM-dd'.  The formula will still be valid, so if the Datum value is 2024-09-22 and the addDays expression +15 equals 2024-09-22 this works.  This essentially does exactly what you want to do with the updated format.  Please edit, save, and retest.
     
     
    ------------------------------------------------


    If this was helpful, please like and/or mark as a verified answer to help others find this too!


    Always glad to help! 💯💯💯💯💯

    Tom 

    Follow me on LinkedIn - Thomas Rice, PMP | LinkedIn

     

     
  • Verified answer
    ND3 Profile Picture
    34 on at
    Hello
     
    thank you for your suggestion, unfortunately it still gives the same error.
    For some reason it does not want to handle formula manipulating a date entry as a string in an array.
     
    I have fixed it by changing the formula:
    this works for me:
     
    @and
    (
    less(item()['Datum'], startOfMonth(addDays(utcNow(), 45))),
    greater(item()['Datum'], startOfMonth(addDays(utcNow(), 15)))
    )
     
    So i do not manipulate the item()['Datum']. Very glad to see the bolean operator work correctly on dates.
    This gives me all the entry's for the next month.
     
    Greets!

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

#2
Tomac Profile Picture

Tomac 296 Moderator

#3
abm abm Profile Picture

abm abm 232 Most Valuable Professional

Last 30 days Overall leaderboard