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
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Top Solution Authors
Top Kudoed Authors
Users online (15,673)