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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / How to filter a ShareP...
Power Automate
Suggested Answer

How to filter a SharePoint list by custom date function using ODATA filter query

(0) ShareShare
ReportReport
Posted on by

I have a list on SharePoint that records various items of equipment and when their maintenance expiry dates are. I want to be able to, on a weekly basis, pull the list into a Power Automate flow, filter out all the rows (i.e. items of equipment) which do not have a maintenance expiry date and then filter again the rows that are left whose expiry date is less than 42 days (6 weeks) away. I would then send an email to the relevant person about whichever items remain. The column variables are:

  • "Maintenance Date" = the last date that maintenance was performed; this column is of the Date and Time format.

  • "Maintenance Period" = the length of time before the next maintenance is required in months (e.g. "12" = 12 months); this is a "Single line of text" column.

I can filter out the rows which do not have a maintenance period:

Maintenance_x0020_Period ne ''

My issue is trying to filter out rows by columns of the Date and Time format, as the flow is returning an error saying that the date formats aren't a match, but trying to use formatDateTime doesn't seem to work. The kind of thing I want to have is this:

Maintenance_x0020_Period ne '' and (@{'addToTime(Maintenance_x0020_Date, Maintenance_x0020_Period, 'month')'} le @{'addDays(utcNow(),42)'})

This way, the blanks are removed and only the items within 42 days of their maintenance expiry date would be left.

TIA

I have the same question (0)
  • Suggested answer
    Ellis Karim Profile Picture
    12,163 Super User 2026 Season 1 on at
     
    (1) To filter out the rows which do not have a maintenance period (this column is a text), try the following in the Get Items filter query:
    Maintenance_x0020_Period ne null
    or to be safe:
    (Maintenance_x0020_Period ne null) or (Maintenance_x0020_Period ne '')
     
    (2) Use a Filter array action after the Get Items to filter items whose expiry date is less than 42 days (6 weeks) away.
     
    As the Maintenance_x0020_Period column is text, you will need to convert it to an integer to perform the maths:
    int(item()['Maintenance_x0020_Period'])
    something like:
    addToTime(item()['Maintenance_x0020_Date'], int(item()['Maintenance_x0020_Period']), 'month')
     
    (3) Compare dates by excluding the time component.
     
    I think you need to remove the time component and only compare the date part. If so, use the format specifier yyyy-MM-dd in the addDays() and addToTime() functions:
    addDays(utcNow(),42, 'yyyy-MM-dd')
    
    addToTime(item()['Maintenance_x0020_Date'], int(item()['Maintenance_x0020_Period']), 'month', 'yyyy-MM-dd')
     
     
     
    Ellis Karim
    Ellis Karim
    elliskarim.com  |  LinkedIn  |  Bluesky
    If this solved your issue, please mark it as ✅ Accepted Answer. If it helped, feel free to give it a 🩷 Like!

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Valantis Profile Picture

Valantis 377

#2
11manish Profile Picture

11manish 279

#3
David_MA Profile Picture

David_MA 234 Super User 2026 Season 1

Last 30 days Overall leaderboard