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

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

View solution in original post

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
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

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