cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
rho1967
Helper III
Helper III

Filter between now() and now()+24 hours

I would like to create a filter like RESDET_AANKOMST >=now() and RESDET_AARKOMST <=now() + 24 hours.

RESDET_Arrival looks like 2022-05-18 09:00:00:00 (datetime) in the table

I thought something like the following but also get a delegation warning (see image) SortByColumns(Filter('Room.vwRoomSetup',RESDET_AARST>=Now(),(DateValue(Text(RESDET_AARKOMST,DateTimeFormat.LongDateTime))<=Today()+1), LOK2="AAA" Or LOK2="BBB"),"RESDET_ARRIVAL",Ascending,"BI_DESCRIPTION",Ascending)

 

Regards

 

1 ACCEPTED SOLUTION

Accepted Solutions
WarrenBelz
Super User
Super User

Hi @rho1967 ,

I will give you two possibilities here - the first if the newest 500 records (you can increase this to 2,000) will do the job

With(
   {
      wList:
      Sort(
         'Room.vwRoomSetup',
         ID,
        Descending 
      )
   },
   SortByColumns(
      Filter(
         wList,
         RESDET_AARST >= Now() &&
         (
            DateValue(
               Text(
                  RESDET_AARKOMST,
                  DateTimeFormat.LongDateTime
               )
            ) <= Today()+1
         ) &&
         (
            LOK2="AAA" ||
            LOK2="BBB"
         )
      ),
      "RESDET_ARRIVAL",
      Ascending,
      "BI_DESCRIPTION",
      Ascending
   )
)

but your issue is actually here

DateValue(
   Text(
      RESDET_AARKOMST,
      DateTimeFormat.LongDateTime
   )
) 

If you are looking for 24 hours

With(
   {
      wNow: Now(),
      w24:
      DateAdd(
         Now(),
         24,
         Hours
      )
   },
   SortByColumns(
      Filter(
         'Room.vwRoomSetup',
         RESDET_AARST >= wNow &&
         RESDET_AARKOMST <= w24 &&
	     (
            LOK2="AAA" ||
            LOK2="BBB"
         )
      ),
      "RESDET_ARRIVAL",
      Ascending,
      "BI_DESCRIPTION",
      Ascending
   )
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Visit my blog Practical Power Apps

View solution in original post

1 REPLY 1
WarrenBelz
Super User
Super User

Hi @rho1967 ,

I will give you two possibilities here - the first if the newest 500 records (you can increase this to 2,000) will do the job

With(
   {
      wList:
      Sort(
         'Room.vwRoomSetup',
         ID,
        Descending 
      )
   },
   SortByColumns(
      Filter(
         wList,
         RESDET_AARST >= Now() &&
         (
            DateValue(
               Text(
                  RESDET_AARKOMST,
                  DateTimeFormat.LongDateTime
               )
            ) <= Today()+1
         ) &&
         (
            LOK2="AAA" ||
            LOK2="BBB"
         )
      ),
      "RESDET_ARRIVAL",
      Ascending,
      "BI_DESCRIPTION",
      Ascending
   )
)

but your issue is actually here

DateValue(
   Text(
      RESDET_AARKOMST,
      DateTimeFormat.LongDateTime
   )
) 

If you are looking for 24 hours

With(
   {
      wNow: Now(),
      w24:
      DateAdd(
         Now(),
         24,
         Hours
      )
   },
   SortByColumns(
      Filter(
         'Room.vwRoomSetup',
         RESDET_AARST >= wNow &&
         RESDET_AARKOMST <= w24 &&
	     (
            LOK2="AAA" ||
            LOK2="BBB"
         )
      ),
      "RESDET_ARRIVAL",
      Ascending,
      "BI_DESCRIPTION",
      Ascending
   )
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Visit my blog Practical Power Apps

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Users online (4,750)