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 / Check if time on submi...
Power Apps
Answered

Check if time on submit is smaller than a certain time + other constraint

(1) ShareShare
ReportReport
Posted on by 1,430

So I have to make a lunch app in PowerApps, the app is created from a Sharepoint list.

Now there are some time restrictions I have to deal with, so this is the case:

 

-The employees can order a sandwich before 9:45 AM the same day and;

-The rest of the day they can order for any other day of the year

 

So I assume I have to do the check on the OnSelect of the Submit button but I can't really figure out the exact formula to get it right.

Anyone have other ideas? Please let me know because this is a crucial part of the app. All help will be appreciated.

 

This is what I tried: If(DataCardValue6 < TimeValue("9:45"),SubmitForm(EditForm1),DataCardValue6.SelectedDate > Today(),SubmitForm(EditForm1),ErrorKind.Conflict)This is what I tried: If(DataCardValue6 < TimeValue("9:45"),SubmitForm(EditForm1),DataCardValue6.SelectedDate > Today(),SubmitForm(EditForm1),ErrorKind.Conflict)

Also how do I show the error message after?

 

 Kind regards

 

Tom

Categories:
I have the same question (0)
  • Meneghino Profile Picture
    6,949 on at

    Hi @Tom_Slosse

     

    Please try this:

     

    If(DataCardValue6.SelectedDate > Today() ||
    (IsToday(DataCardValue6.SelectedDate) &&
    (Hour(Now())<9 || (Hour(Now())=9 && Minute(Now())<=45)))
     ,
    SubmitForm(EditForm1)
    )

    Basically the submit form action will only happen if the conditions are met, if not, then nothing happens.

  • Verified answer
    Meneghino Profile Picture
    6,949 on at

    PS However, I would do it another way.

     

    I would use exactly the same conditions, but would set the Disabled property of the submit button/icon instead.

    Hence Disabled to this:

    Not(DataCardValue6.SelectedDate > Today() ||
    (IsToday(DataCardValue6.SelectedDate) &&
    (Hour(Now())<9 || (Hour(Now())=9 && Minute(Now())<=45)))
     )

    And OnSelect to this:

    SubmitForm(EditForm1)
  • Tom_Slosse Profile Picture
    1,430 on at

    Meneghino

     

    Thanks for the quick reply!!!

    I would love to test your solution but my lookup field for code gives an error: The lookup service call failed: An error occured on the server.

     

    Ill try to fix it asap and will let you know if it works

     

    Kind regards

     

     

    Tom

  • Tom_Slosse Profile Picture
    1,430 on at

    @Meneghino

     

    I made a record in my SharePoint list and there is something strange happening.

    If you fill in the form in SharePoint there is no problem, but if you start up the powerapp and refresh your records

    then you see in the record that the date isn't correct. It takes the date of yesterday instead.

     

    SP_Date.PNGPA_Date.PNG

    Could it be that I should check first on IsToday and then on the next day?

     

    Kind regards

     

    Tom

  • Meneghino Profile Picture
    6,949 on at

    Hi @Tom_Slosse

     

    The issue is related to the way dates are treated by different systems in different time zones.  Your SharePoint server is probably in a different time zone from you, or the date is written to SharePoint in UTC but then SharePoint treates this as local, or viceversa. All very messy.

     

    In brief, I would strongly recommend to store dates as yyyy-mm-dd text in a text column, that you can then parse when needed.

     

    Otherwise you always have to worry about time zones.

     

    Here is one post from me:

    https://powerusers.microsoft.com/t5/PowerApps-Forum/Please-help-with-UTC/m-p/21244

     

    And many many more....

    https://powerusers.microsoft.com/t5/forums/searchpage/tab/message?filter=location&location=category%3APowerApps1&q=time+zone

  • Meneghino Profile Picture
    6,949 on at

    PS The fact that you set a column to date only in SharePoint or is many other database systems does not help.  This is because it does not display the time portion, but this lives on in the database, creating the issues you and others see.

  • Tom_Slosse Profile Picture
    1,430 on at

    @Meneghino

     

    Thanks for the tip but the weird thing is that it worked in another app with the same layout (testapp of my lunch). Only displaying date en it shows perfectly in the powerapp as it should it is only with this app it freaks out.

     

    TestApp_Date.PNGTestApp_PA_Dae.PNG

     

    So its weird it doesnt work properly anymore.

     

    Kind Regards

     

     

    Tom

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 April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 610

#2
Haque Profile Picture

Haque 317

#3
WarrenBelz Profile Picture

WarrenBelz 315 Most Valuable Professional

Last 30 days Overall leaderboard