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 Apps / How to filter items de...
Power Apps
Answered

How to filter items depends on date range?

(0) ShareShare
ReportReport
Posted on by 255

Hi, 

I would like to ask for help. I have SP list which contains two datetime columns (start_day, end_day). 

And I need filter all items which are in date range. Date range is set to -2days from Now() and +10days from Now()

For example:

Item IDstart_dayend_dayresult
115.12.202220.12.2022not shown (wrong)
219.12.202221.12.2022shown (correct)
315.12.202223.12.2022not shown (wrong)

1 and 3 ID could be shown.  

 

'Datum nakládky' = start_day

 

My filter expression is:
Filter(
'Evidence přepravy_1';//zdroj udajov filtru
'Datum nakládky' >=(DateAdd(
Now();
-2;
Days
)) And 'Datum nakládky' <= (DateAdd(
Now();
10;
Days
));

So I need to shown all items in date range. Can anybody give me advice? Thanks. 

Categories:
  • v-bofeng-msft Profile Picture
    Microsoft Employee on at

    Hi @TomasG ,

     

    Please try:

    Filter(
     'Evidence přepravy_1';//zdroj udajov filtru
     Date(Last(Split('Datum nakládky';".")).Result;Last(FirstN(Split('Datum nakládky';"."),2)).Result;First(Split('Datum nakládky';".")).Result) >=(DateAdd(Now();-2;Days)) And 
     Date(Last(Split('Datum nakládky';".")).Result;Last(FirstN(Split('Datum nakládky';"."),2)).Result;First(Split('Datum nakládky';".")).Result) <= (DateAdd(Now();10;Days)
    );

     

    Best Regards,

    Bof

  • TomasG Profile Picture
    255 on at

    Hi @v-bofeng-msft, 

    thanks for replay. I try it, but there is some problem. I think it ist caused by time value of datetime. Column in SP is date and time column. 

    There some error message "2022 16:00 could not be convert" 

  • Verified answer
    victorcp Profile Picture
    2,350 Moderator on at

    Hi,

    In your cenario I think you want to show all item that has any date between your time range right? if so there are 3 conditions that you have to consider:

    1 - start date is between the time range

    2 - end date is between the time range

    3 -  the time range is between start and end date

    in this case the filter will be something like this:

    With({Less2Days: DateAdd(Now(),-2,Days), Plus10Days:DateAdd(Now(),10,Days)},
     Filter(
     dates,
     Start>=Less2Days && Start<=Plus10Days || // check if start date is between the time range
     End>=Less2Days && End<=Plus10Days || // check if end date is between the time range
     Start<=Less2Days && End>=Plus10Days // Check if time range is between start and end date
     )
    )

     

    I hope it helps 🙂

  • TomasG Profile Picture
    255 on at

    Hi, 

    thanks for help. This is correct sollution.

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 Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 354 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 330

#3
Mohsin Ali Profile Picture

Mohsin Ali 232

Last 30 days Overall leaderboard