cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
NewNW
Level: Powered On

How to filter date and time range

Hi all,

I have a two Calendar to book a computer from date to return date. Also I m asking the pickup time and return time as well. All data will store in SharePoint online list.

The requirement is- 

User will search avaliable computer based on the pickup date and time.

So now I want to find the available computers within the pickup date and time range. 

eg-

 

Date from - 28/04/2019( datefromSharePoint filed)       Date return- 02/05/2019( datetoSharePoint filed)

Pickup Time- 11.00 a.m ( TimefromSharePoint filed)       Return time- 9.00 a.m ( TimeToSharePoint filed)

 

Can soemone please tell me how can I search SharePoint online list to chcek all laptops that are not booked within the above range and display in a grid (FYI I have a field in SP list called computer returned-Yes/No). Also how user will be able to click on the desired latop from the grid to book it?

Many thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
NewNW
Level: Powered On

Re: How to filter date and time range

Hi,

Finally I manged to do as follows

Filter(
'CarDetails',
Not(
CarRegistrationNumber in Filter('BookingDetails',( ((DateValue(Text(PickupDate, "[$-en-US]mm/dd/yyyy")) + Time(Value(PickupTime), 0, 0))
<= (DateValue(Text(dtpPickupDate.SelectedDate,"[$-en-US]mm/dd/yyyy")) + Time(Value(dpdPickupTime.Selected.Value), 0, 0)) &&
(DateValue(Text(DropoffDate, "[$-en-US]mm/dd/yyyy")) + Time(DropoffTime, 0,0)) >=
(DateValue(Text(dtpDropOffDate.SelectedDate, "[$-en-US]mm/dd/yyyy")) + Time(Value(dpdDropoffTime.Selected.Value), 0, 0))) ||
((DateValue(Text(PickupDate, "[$-en-US]mm/dd/yyyy")) + Time(Value(PickupTime), 0, 0))
>= (DateValue(Text(dtpPickupDate.SelectedDate,"[$-en-US]mm/dd/yyyy")) + Time(Value(dpdPickupTime.Selected.Value), 0, 0)) &&
(DateValue(Text(PickupDate, "[$-en-US]mm/dd/yyyy")) + Time(PickupTime, 0,0)) <=
(DateValue(Text(dtpDropOffDate.SelectedDate, "[$-en-US]mm/dd/yyyy")) + Time(Value(dpdDropoffTime.Selected.Value), 0, 0))) ||
((DateValue(Text(DropoffDate, "[$-en-US]mm/dd/yyyy")) + Time(Value(DropoffTime), 0, 0))
>= (DateValue(Text(dtpPickupDate.SelectedDate,"[$-en-US]mm/dd/yyyy")) + Time(Value(dpdPickupTime.Selected.Value), 0, 0)) &&
(DateValue(Text(DropoffDate, "[$-en-US]mm/dd/yyyy")) + Time(DropoffTime, 0,0)) <=
(DateValue(Text(dtpDropOffDate.SelectedDate, "[$-en-US]mm/dd/yyyy")) + Time(Value(dpdDropoffTime.Selected.Value), 0, 0)))||
((DateValue(Text(DropoffDate, "[$-en-US]mm/dd/yyyy")) + Time(Value(DropoffTime), 0, 0))
<= (DateValue(Text(dtpDropOffDate.SelectedDate,"[$-en-US]mm/dd/yyyy")) + Time(Value(dpdDropoffTime.Selected.Value), 0, 0)) &&
(DateValue(Text(PickupDate, "[$-en-US]mm/dd/yyyy")) + Time(PickupTime, 0,0)) >=
(DateValue(Text(dtpPickupDate.SelectedDate, "[$-en-US]mm/dd/yyyy")) + Time(Value(dpdPickupTime.Selected.Value), 0, 0)))
)).CarRegistrationNumber
)
)

View solution in original post

7 REPLIES 7
Community Support Team
Community Support Team

Re: How to filter date and time range

Hi @NewNW ,

Could you please share a bit more about the data structure of your SP list?

Which type column do you used within your SP list to store the PickUp time and Return time value? Using Date and Time type column?

 

If you created Date type columns in your SP list to store the Date from and Date Return value, and created Date and Time type columns in your SP list to store the Pickup time and Return time value:

I have made a test on my side, please take a try with the following workaround:

Add a Data Table control within your app, set the Items property to following:

Filter(
         'YourSPList',
          datefrom + Time(Value(Hour(Timefrom)), Value(Minute(Timefrom)),0) > DateTimeValue("04/28/2019 11:00 am") && dateto + Time(Value(Hour(Timeto)), Value(Minute(Timeto)),0) < DateTimeValue("05/02/2019 09:00 am"),
'computer returned' = false )

Note: I assume that the 'computer returned ' = false represents the laptops that are not booked within your SP List. The datefrom and dateto represents the Date type column in your SP list, the Timefrom and Timeto column represents the Date & Time column in your SP list.

 

In addition, if you want to click on the desired latop from above Data Table to book it, I have made a test on my side, please take a try with the following workaround:3.JPG

 

4.JPG

Set the Items property of the Data Table to following:

AddColumns('20190325_case13', "Book Button", "Book")

On your side, you should type:

AddColumns(
Filter(
'YourSPList',
datefrom + Time(Value(Hour(Timefrom)), Value(Minute(Timefrom)),0) > DateTimeValue("04/28/2019 11:00 am") && dateto + Time(Value(Hour(Timeto)), Value(Minute(Timeto)),0) < DateTimeValue("05/02/2019 09:00 am"),
'computer returned' = false
),
"Book Button",
"Book"
)

Within the Data Table, enable the "Book Button" field. Then select the "Book Button" field, set IsHyperlink property to true

Set the OnSelect property of the "Book Button" column to following:

Patch('20190325_case13', LookUp('20190325_case13', ID=DataTable1.Selected.ID),{Checked: false}) /* <-- '20190325_case13' is my SP List */

On your side, you should type:

Patch(
'YourSPList',
LookUp('YourSPList', ID = DataTable1.Selected.ID),
{'computer returned': true}
)

Note: I assume that the 'computer returned' column is a Yes/No type column in your SP list. When the 'computer returned' set to false, it means that the corresponding Laptop has not been booked.

 

Please take a try with above solution, check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
NewNW
Level: Powered On

Re: How to filter date and time range

Thank you very much V-Xida-Mstf,

List.png

Community Support Team
Community Support Team

Re: How to filter date and time range

Hi @NewNW ,

Based on the needs that you mentioned, please consider modify above Filter formula as below:

Filter(
         'YourSPList', 
         (DateValue(Text(PickupDate, "mm/dd/yyyy")) + Time(Value(PickupTime), 0, 0)) > (DateValue(Text(PickupDatePicker.SelectedDate,"mm/dd/yyyy")) + Time(Value(PickupTimeDropdown.Selected.Value), 0, 0)),
(DateValue(Text(DropoffDate, "mm/dd/yyyy")) + Time(DropoffTime, 0,0)) < (DateValue(Text(DropoffDatePicker.SelectedDate, "mm/dd/yyyy")) + Time(Value(DropoffTimeDropdown.Selected.Value), 0, 0)) )

Note: I assume that the PickupTime and DropoffTime are both Number type columns in your SP list.

 

In addition, if you want to book the laptop within the Data Table, please take a try with the solution I provided in previous reply, and replace the Filter formula with above Filter function:

AddColumns(
           Filter(
'YourSPList',
(DateValue(Text(PickupDate, "mm/dd/yyyy")) + Time(Value(PickupTime), 0, 0)) > (DateValue(Text(PickupDatePicker.SelectedDate,"mm/dd/yyyy")) + Time(Value(PickupTimeDropdown.Selected.Value), 0, 0)),
(DateValue(Text(DropoffDate, "mm/dd/yyyy")) + Time(DropoffTime, 0,0)) < (DateValue(Text(DropoffDatePicker.SelectedDate, "mm/dd/yyyy")) + Time(Value(DropoffTimeDropdown.Selected.Value), 0, 0))
), "Book Button", "Book" )

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
NewNW
Level: Powered On

Re: How to filter date and time range

Thanks for your reply, with your query how can I filter out the cars already bpoooked within the selected time frame?

Community Support Team
Community Support Team

Re: How to filter date and time range

Hi @NewNW ,

How do you recognize a car has been boooked?

 

If you want to filter out the cars (from 'car detail' list) already booked within the Data Table, please set the Items property of the Data Table to following:

Filter(
         'Your Car Detail List',
          Not(
CarRegistrationNumber in Filter('Booking Details List', (DateValue(Text(PickupDate, "mm/dd/yyyy")) + Time(Value(PickupTime), 0, 0)) > (DateValue(Text(PickupDatePicker.SelectedDate,"mm/dd/yyyy")) + Time(Value(PickupTimeDropdown.Selected.Value), 0, 0)), (DateValue(Text(DropoffDate, "mm/dd/yyyy")) + Time(DropoffTime, 0,0)) < (DateValue(Text(DropoffDatePicker.SelectedDate, "mm/dd/yyyy")) + Time(Value(DropoffTimeDropdown.Selected.Value), 0, 0))).CarRegistrationNumber
) )

Please take a try with above solution, check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
NewNW
Level: Powered On

Re: How to filter date and time range

Hi V-xida-msf,

Now the data table filtering based on the qurey condition, but I m thinking the condition is not correct , see below screenshot.

Capture1.PNG

Capture2.PNG

The car registration ZVK364 should not display on the data table based on the Pickup and Drop off date selection.

Any sugestion please.

Im thinking I need somethiing like following, but it is not working.

Filter(
'CarDetails',
Not(
CarRegistrationNumber in Filter('BookingDetails', ((DateValue(Text(PickupDate, "[$-en-US]mm/dd/yyyy")) + Time(Value(PickupTime), 0, 0)) > (DateValue(Text(dtpPickupDate.SelectedDate,"[$-en-US]mm/dd/yyyy")) + Time(Value(dpdPickupTime.Selected.Value), 0, 0))&&
(DateValue(Text(PickupDate, "[$-en-US]mm/dd/yyyy")) + Time(Value(PickupTime), 0, 0)) > (DateValue(Text(dtpDropOffDate.SelectedDate,"[$-en-US]mm/dd/yyyy")) + Time(Value(dpdDropoffTime.Selected.Value), 0, 0)))

||(DateValue(Text(DropoffDate, "[$-en-US]mm/dd/yyyy")) + Time(DropoffTime, 0,0)) < (DateValue(Text(dtpPickupDate.SelectedDate, "[$-en-US]mm/dd/yyyy")) + Time(Value(dtpPickupDate.Selected.Value), 0, 0))&&
(DateValue(Text(DropoffDate, "[$-en-US]mm/dd/yyyy")) + Time(DropoffTime, 0,0)) < (DateValue(Text(dtpDropOffDate.SelectedDate, "[$-en-US]mm/dd/yyyy")) + Time(Value(dtpDropOffDate.Selected.Value), 0, 0))).CarRegistrationNumber
)
)

Thanks.

NewNW
Level: Powered On

Re: How to filter date and time range

Hi,

Finally I manged to do as follows

Filter(
'CarDetails',
Not(
CarRegistrationNumber in Filter('BookingDetails',( ((DateValue(Text(PickupDate, "[$-en-US]mm/dd/yyyy")) + Time(Value(PickupTime), 0, 0))
<= (DateValue(Text(dtpPickupDate.SelectedDate,"[$-en-US]mm/dd/yyyy")) + Time(Value(dpdPickupTime.Selected.Value), 0, 0)) &&
(DateValue(Text(DropoffDate, "[$-en-US]mm/dd/yyyy")) + Time(DropoffTime, 0,0)) >=
(DateValue(Text(dtpDropOffDate.SelectedDate, "[$-en-US]mm/dd/yyyy")) + Time(Value(dpdDropoffTime.Selected.Value), 0, 0))) ||
((DateValue(Text(PickupDate, "[$-en-US]mm/dd/yyyy")) + Time(Value(PickupTime), 0, 0))
>= (DateValue(Text(dtpPickupDate.SelectedDate,"[$-en-US]mm/dd/yyyy")) + Time(Value(dpdPickupTime.Selected.Value), 0, 0)) &&
(DateValue(Text(PickupDate, "[$-en-US]mm/dd/yyyy")) + Time(PickupTime, 0,0)) <=
(DateValue(Text(dtpDropOffDate.SelectedDate, "[$-en-US]mm/dd/yyyy")) + Time(Value(dpdDropoffTime.Selected.Value), 0, 0))) ||
((DateValue(Text(DropoffDate, "[$-en-US]mm/dd/yyyy")) + Time(Value(DropoffTime), 0, 0))
>= (DateValue(Text(dtpPickupDate.SelectedDate,"[$-en-US]mm/dd/yyyy")) + Time(Value(dpdPickupTime.Selected.Value), 0, 0)) &&
(DateValue(Text(DropoffDate, "[$-en-US]mm/dd/yyyy")) + Time(DropoffTime, 0,0)) <=
(DateValue(Text(dtpDropOffDate.SelectedDate, "[$-en-US]mm/dd/yyyy")) + Time(Value(dpdDropoffTime.Selected.Value), 0, 0)))||
((DateValue(Text(DropoffDate, "[$-en-US]mm/dd/yyyy")) + Time(Value(DropoffTime), 0, 0))
<= (DateValue(Text(dtpDropOffDate.SelectedDate,"[$-en-US]mm/dd/yyyy")) + Time(Value(dpdDropoffTime.Selected.Value), 0, 0)) &&
(DateValue(Text(PickupDate, "[$-en-US]mm/dd/yyyy")) + Time(PickupTime, 0,0)) >=
(DateValue(Text(dtpPickupDate.SelectedDate, "[$-en-US]mm/dd/yyyy")) + Time(Value(dpdPickupTime.Selected.Value), 0, 0)))
)).CarRegistrationNumber
)
)

View solution in original post

Helpful resources

Announcements
thirdimage

Power Apps Super User Class of 2020

Check it out!

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors (Last 30 Days)
Users online (5,231)