web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Booking check against ...
Power Apps
Answered

Booking check against selected dates and time

(3) ShareShare
ReportReport
Posted on by 125

Hello

 

I'm building a power app for my team to be able to pre book lab equipment for use.

 

I have a SP list with the following columns

Title - Asset ID - Single line of text

Start Date - Date and time

End Date - Date and time

Booked by - Person or group

 

Within the app I have a calendar view so the user can click on dates and see if equipment is already booked on those days in a gallery. 

Then next to that there is a form when a user can select the dates and times they want to book items out for.

A TextInput populated by a variable for the asset ID selected

A start date picker called StartDateValue with hour and minute pickers called StartHourValue and StartMinValue

An end date picker called EndDateValue with hour and minute pickers called EndHourValue and EndMinValue

 

Then there is a confirmation button, on pressing the button I'd like the app to check if the SP list has the asset ID booked out on any of the selected dates, if it does, it notifies the user that the item is already booked at that time, if it doesn't it lets the user know the booking has been successful.

 

Chwilkinson_0-1667464170796.png

I've used this logic to make sure I capture any overlapping bookings.

 

When I run my app and make a booking, I'm getting both the error and succuss notifications and the bookings are being saved to my SP list even if there is a clash.

 

Any advice would be really helpful,

 

Thank you.

 

on select 

 

If(

LookUp

('Asset Booking Calendar', Title = AssetID_TextInput.Text &&

 

((StartDateValue.SelectedDate +

Time(

Value(StartHourValue.Selected.Value),

Value(StartMinuteValue.Selected.Value),

0)

 <= 'Start Date' )

&&

(EndDateValue.SelectedDate +

Time(

Value(EndHourValue.Selected.Value),

Value(EndMinuteValue.Selected.Value),

0)

>= 'End Date'))

||

((StartDateValue.SelectedDate +

Time(

Value(StartHourValue.Selected.Value),

Value(StartMinuteValue.Selected.Value),

0)

<= 'Start Date' )

&&

(EndDateValue.SelectedDate +

Time(

Value(EndHourValue.Selected.Value),

Value(EndMinuteValue.Selected.Value),

0)

>= 'Start Date'))

||

((StartDateValue.SelectedDate +

Time(

Value(StartHourValue.Selected.Value),

Value(StartMinuteValue.Selected.Value),

0)

<= 'End Date' )

&&

(EndDateValue.SelectedDate +

Time(

Value(EndHourValue.Selected.Value),

Value(EndMinuteValue.Selected.Value),

0)

>= 'End Date'))

||

((StartDateValue.SelectedDate +

Time(

Value(StartHourValue.Selected.Value),

Value(StartMinuteValue.Selected.Value),

0)

>= 'Start Date' )

&&

(EndDateValue.SelectedDate +

Time(

Value(EndHourValue.Selected.Value),

Value(EndMinuteValue.Selected.Value),

0)

            <= 'End Date')));

 

        Notify("This asset is already booked at this time",NotificationType.Error),

 

SubmitForm(Form1);

Notify("Your booking has been successfully made", NotificationType.Success);

NewForm(Form1)

);

Categories:
I have the same question (0)
  • Verified answer
    Chwilkinson Profile Picture
    125 on at

    Hi 

    I managed to work this out myself, so sharing the solution in case its useful for anyone else in the future.

     

     

    If(
       LookUp('Asset Booking Calendar',
          Title = AssetID_TextInput.Text &&

    (('Start Date' >=

    StartDateValue.SelectedDate +

    Time(

    Value(StartHourValue.Selected.Value),

    Value(StartMinuteValue.Selected.Value),

    0)

    &&

    'End Date' <=

    EndDateValue.SelectedDate +

    Time(

    Value(EndHourValue.Selected.Value),

    Value(EndMinuteValue.Selected.Value),

    0))

    ||

    ('Start Date' <=

    EndDateValue.SelectedDate +

    Time(

    Value(EndHourValue.Selected.Value),

    Value(EndMinuteValue.Selected.Value),

    0)

    &&

    'End Date' >=

    EndDateValue.SelectedDate +

    Time(

    Value(EndHourValue.Selected.Value),

    Value(EndMinuteValue.Selected.Value),

    0))

    ||

    ('Start Date' <=

    StartDateValue.SelectedDate +

    Time(

    Value(StartHourValue.Selected.Value),

    Value(StartMinuteValue.Selected.Value),

    0)

    &&

    'End Date' >=

    StartDateValue.SelectedDate +

    Time(

    Value(StartHourValue.Selected.Value),

    Value(StartMinuteValue.Selected.Value),

    0)

    )),
        true
       ),
       Notify("This asset is already booked at this time",NotificationType.Error),
     

    SubmitForm(Form1);

    Notify("Your booking has been successfully made", NotificationType.Success);

    NewForm(Form1)
    )

  • markoram Profile Picture
    28 on at

    Just wanted to thank you for your posting of your solution. In didn't exactly work for the situation I had to deal with, however breaking down your coding elements and using countif instead of lookup helped solve the problem perfectly!

  • PA_Forum_User Profile Picture
    71 on at

    Hello Mr. Wilkinson.

     

    I also want to thank you for your post. It is truly useful!

     

    Have a nice day! God bless!

  • whykay1029 Profile Picture
    on at

    thank you for this formula, I have a similar app to yours. mine is room booking

    I have a room booked for 21st of May to 22nd of may. another booking for the same room from 23rd to 24th. there is need for the first booking to be extended, i need to cancel the second booking and book another room for the second booking. for the first i need to now extend it to 24th. how do i go about it.

  • PA_Forum_User Profile Picture
    71 on at

    The user has to delete both bookings, and redo the bookings all in 1, so 21-24. Implementing a logic that always cheks and "feels" that user X has two bookings of consecutive days, than can be grouped is a massive overkill for such an app.

    Once the users learn how to use the app, they will be carefull and book a single or an interval (of multiple) days.

     

    PS: NEVER ever let the users book the current day. Always make them the bookings STARTING current day + 1 (tomorrow).

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 541

#2
WarrenBelz Profile Picture

WarrenBelz 434 Most Valuable Professional

#3
Valantis Profile Picture

Valantis 289

Last 30 days Overall leaderboard