cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Verlet
Frequent Visitor

Filter gallery by today's date AND hour

Hey all,

 

I got a SharePoint list with shifts (kind of calendarlist). In Power Apps I want to show the shifts that are currently (in this moment) active.

For example: Fred, shift from 01/01/2020 1am-6am; Adele, shift from 01/01/2020 6am-6pm & Frank, shift from 01/01/2020 6pm- 01/02/2020 1am. This moment is 01/01/2020, 10am, so I only want to see Adele in my gallery. Unfortunately, it always shows me the 3 shifts with this code (in Items of Gallery):

 

Filter('Shiftlist';DateValue(Text(Startdate;"[$-en-US]dd/mm/yyyy HH:mm"))<=DateValue(Text(Today();"[$-en-US]dd/mm/yyyy HH:mm"))&&DateValue(Text(Enddate;"[$-en-US]dd/mm/yyyy HH:mm"))>=DateValue(Text(Today();"[$-en-US]dd/mm/yyyy HH:mm")))

 

Any ideas what's wrong?

 

1 ACCEPTED SOLUTION

Accepted Solutions

@Verlet 

Perhaps this is a silly question.  Is the Text formatting necessary here? It appears we are working with dates already.  Also can we assume the data is in a gallery and ThisItem can be used as a reference?

 

 

Filter('Shiftlist'; Startdate < Now() And Enddate > Now())

 

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

View solution in original post

5 REPLIES 5
mdevaney
Super User
Super User

@Verlet 
Can you please try changing any references in your code to the function TODAY() in NOW() instead?

Filter(
    'Shiftlist';
    DateValue(Text(Startdate;"[$-en-US]dd/mm/yyyy HH:mm"))<=DateValue(Text(Now();"[$-en-US]dd/mm/yyyy HH:mm"))
    &&DateValue(Text(Enddate;"[$-en-US]dd/mm/yyyy HH:mm"))>=DateValue(Text(Now();"[$-en-US]dd/mm/yyyy HH:mm"))
)

 

 

The NOW() function includes time so I think it will work better here.

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

Verlet
Frequent Visitor

@mdevaney , thank you for the idea, but it didn't work. It keeps on showing every item where today's date is in the time span and not only the current item 😕

@Verlet 

Perhaps this is a silly question.  Is the Text formatting necessary here? It appears we are working with dates already.  Also can we assume the data is in a gallery and ThisItem can be used as a reference?

 

 

Filter('Shiftlist'; Startdate < Now() And Enddate > Now())

 

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

Verlet
Frequent Visitor

@mdevaney, sometimes keep it simple is best indeed... The ThisItem is unnecessary (as it refers to columns) but it works! 

Filter('Shiftlist'; Startdate<Now() And Enddate>Now() )

If you change that to your response I'll accept it as the solution.

Thanks for your help!!

@Verlet 

Its now changed Verlet.  Thank you!

Helpful resources

Announcements
October Events

Mark Your Calendars

So many events that are happening this month - don't miss out!

Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Top Solution Authors
Top Kudoed Authors
Users online (2,856)