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 Apps / Get gallery items usin...
Power Apps
Answered

Get gallery items using a datetime range

(0) ShareShare
ReportReport
Posted on by 18

Hi Everyone,

 

Example: If date today is 31/03/2024 I need my gallery to get all items going back to 01/03/2024 12:00PM.

So anything before 01/03/2024 12:00PM is excluded.

 

My failed attempts at this was only returning PM items. Would greatly appreciate some help on this 🙂

Categories:
I have the same question (0)
  • Verified answer
    mmbr1606 Profile Picture
    14,605 Super User 2025 Season 2 on at

    hey @Righty 

     

    can you try this please:

    // Calculate the start date
    Set(
     startDate,
     DateTimeValue(
     Text(
     DateValue(
     Text(Now(), "yyyy-MM") & "-01"
     )
     ) & " 12:00 PM"
     )
    );
    
    // Use this in your gallery's Items property to filter based on the start date
    Filter(
     DataSource,
     yourDateTimeField >= startDate
    )
    

     

    Let me know if my answer helped solving your issue.

    If it did please accept as solution and give it a thumbs up so we can help others in the community.



    Greetings

  • Verified answer
    VishalJhaveri Profile Picture
    1,167 Moderator on at
    Set(StartDate, 
    	DateTimeValue(Text(DateValue(Text(Now(),"yyyy-MM") & "-01"))& " 12:00 PM")
    );
    
    Filter(Source, Column>=StartDate)

     

    This shall definitely work.

  • Righty Profile Picture
    18 on at

    Hey @mmbr1606

     

    I got a error trying this: 'The value '2024-MM-01 cannot be converted to a date or time value.'

     

    When i use the Now() function the output = 06/05/2024, 17:00:34

     

    Im in New Zealand and the date format is dd/MM/yyyy here. Not sure if thats the issue?

     

    Thanks

  • Verified answer
    goncalomelo8 Profile Picture
    on at

    Hi @Righty,

     

    Please switch to lower case "m", like this:

    Set(
     startDate,
     DateTimeValue(
     Text(
     DateValue(
     Text(Now(), "yyyy-mm") & "-01"
     )
     ) & " 12:00 PM"
     )
    );

     

    Have a great day!

     

    Kind regards,

    Gonçalo Melo

  • Righty Profile Picture
    18 on at

    Thanks everyone, the code has worked now 🙂

  • VishalJhaveri Profile Picture
    1,167 Moderator on at

    Can you mark my answer as solution, if it all it helped you in any way?

  • Righty Profile Picture
    18 on at

    Hi All,

    I've got a strange problem, so the code works in Chrome and filters items correctly. But in MS Edge the filter completely breaks and shows all items.

     

    I have updated Edge and cleared all cookies and cache but the problem remains.

     

    I even embed into the teams app it works correctly.

     

    Any ideas?

  • Righty Profile Picture
    18 on at

    I managed to fix it, issue is related to the language setting in browser which swapped around to mm/dd. So I force set it in the app by adding the language code argument en-GB. e.g DateValue(var_datetime, "en-GB")

    Which changed it back to dd/mm again

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 Apps

#1
Kalathiya Profile Picture

Kalathiya 408

#2
WarrenBelz Profile Picture

WarrenBelz 382 Most Valuable Professional

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 328 Super User 2025 Season 2

Last 30 days Overall leaderboard