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 Apps
Answered

Two time fields

(0) ShareShare
ReportReport
Posted on by 61

I have an update form that has a start time and an end time which the users enter the relevant times.

How can I ensure that the end time the user enters is not before the start time?

TIA

 

Categories:
I have the same question (0)
  • Nogueira1306 Profile Picture
    7,390 Super User 2024 Season 1 on at

    Hey!

    You can use an if like this:

     

    If( DatePickerStart.SelectedDate > DatePickerEnd.SelectedDate; CREATE FORM; NOTIFY ABOUT ERROR)

     

    If you have a combobox with the hours just check this:

     

    If( Value(DropdownStart.Selected.Value)> Value(DropdownEnd.Selected.Value); CREATE FORM; NOTIFY ABOUT ERROR)

     

    If that gives you error, try without the Value():

     

    If( DropdownStart.Selected.Value >DropdownEnd.Selected.Value; CREATE FORM; NOTIFY ABOUT ERROR)

  • zmansuri Profile Picture
    6,048 Super User 2024 Season 1 on at

    Take a label. Enter text like.

    "End time should be greater than Start Time"

    Set label's visible property:

    StartTime>EndTime

  • mick3911 Profile Picture
    61 on at

    Reading the replies, I have realised that I haven’t explained myself correctly, so I will start again.

     

    I have an update form that has a starthour time, a startminute time, a endhour time and a endminute time where the users enter the relevant times.

     

    I have two labels (TimeStart and TimeEnd) where I have ‘joined’ the starthour & startminute and endhour & endminute together using the following respectively

     

    Text(StartHour.Selected.Value&":"&StartMinute.Selected.Value,DateTimeFormat.LongDateTime24)
    Text(EndHour.Selected.Value&":"&EndMinute.Selected.Value,DateTimeFormat.LongDateTime24)

     

    How can I ensure that the end time the user enters is not the same or before the start time?

     

  • Nogueira1306 Profile Picture
    7,390 Super User 2024 Season 1 on at

    Okay. So, i would do something like this:

     

    1.Set those 2 dates in a var;

     

    2. Check this:

     

    If( varStartDate < varEndDate; Notifiy("Error"); SubmitForm())

     

     

    You can also try a date diff but dont think it will work

     

    If you need additional help please tag me in your reply and please like my reply.
    If my reply provided you with a solution, pleased mark it as a solution ✔️!

    Best regards,
    Gonçalo Nogueira

    Check my LinkedIn!

  • mick3911 Profile Picture
    61 on at

    But I am wanting to do this with time not date.

  • Nogueira1306 Profile Picture
    7,390 Super User 2024 Season 1 on at

    It is the same.....

     

    1.Set those 2 times in a var;

     

    2. Check this:

    If( varStartTime < varEndTime; Notifiy("Error"); SubmitForm())

     

    If you need additional help please tag me in your reply and please like my reply.
    If my reply provided you with a solution, pleased mark it as a solution ✔️!

    Best regards,
    Gonçalo Nogueira

    Check my LinkedIn!

     

  • mick3911 Profile Picture
    61 on at

    This is where I found out I am out of my league a bit with regards to variables.

    How do I set those times in a var?

     

     

  • Nogueira1306 Profile Picture
    7,390 Super User 2024 Season 1 on at
    Set( varStartTime, Text(StartHour.Selected.Value&":"&StartMinute.Selected.Value,DateTimeFormat.LongDateTime24))

     

    If( Value(varStartTime) < Value(varEndTime); Notifiy("Error"); SubmitForm())

     

    If you need additional help please tag me in your reply and please like my reply.
    If my reply provided you with a solution, pleased mark it as a solution ✔️!

    Best regards,
    Gonçalo Nogueira

    Check my LinkedIn!

  • mick3911 Profile Picture
    61 on at

    Under control field do I enter the Set var formula?

  • Nogueira1306 Profile Picture
    7,390 Super User 2024 Season 1 on at

    When you set the text, you set the var

     

    If you need additional help please tag me in your reply and please like my reply.
    If my reply provided you with a solution, pleased mark it as a solution ✔️!

    Best regards,
    Gonçalo Nogueira

    Check my LinkedIn!

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 358 Most Valuable Professional

#2
11manish Profile Picture

11manish 214 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 185

Last 30 days Overall leaderboard