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

Re: Filter gallery by today's date AND hour

@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
Highlighted
Super User III
Super User III

Re: Filter gallery by today's date AND hour

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

Highlighted
Frequent Visitor

Re: Filter gallery by today's date AND hour

@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 😕

Highlighted
Super User III
Super User III

Re: Filter gallery by today's date AND hour

@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

Highlighted
Frequent Visitor

Re: Filter gallery by today's date AND hour

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

Highlighted
Super User III
Super User III

Re: Filter gallery by today's date AND hour

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

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Tech Marathon

Maratón de Soluciones de Negocio Microsoft

Una semana de contenido con +100 sesiones educativas, consultorios, +10 workshops Premium, Hackaton, EXPO, Networking Hall y mucho más!

Top Solution Authors
Top Kudoed Authors
Users online (5,992)