cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
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
Super User III
Super User III

@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."

@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."

View solution in original post

@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
New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

Top Solution Authors
Top Kudoed Authors
Users online (46,785)