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 / Best way to compare va...
Power Apps
Unanswered

Best way to compare values in different Date Picker columns

(0) ShareShare
ReportReport
Posted on by 716

Hello Power Apps Community,

I hope you can help please.

I'm using Dataverse for Teams to build a timesheet app.

I have a Form with a number of Date and Time columns, "Monday Start", "Monday End", "Tuesday Start". "Tuesday End" etc.

 

I want to add some validation, so when the date and time in say the column "Friday Start" is greater than "Friday End" I want to notify the user and stop them saving the form with incorrect data.

 

Currently, as a test, on one of the columns, "Friday Start", on the "HourValue" part of the datacard I've added this formula:

If(
         crdFridayStart.Update > crdFridayEnd.Update,
         Notify(
                     "Day Start hour is greater than day End hour. Adjust your Start hour to be earlier than your End hour",
                     NotificationType.Error,
                     10000
                   ),
        false
)

This notifies the user but still allows them to save the record. This test, or course, is not what I really want.

 

GarryPope_0-1626004228744.png

 

 

I want the entire datacard of the "Friday Start" to be compared with "Friday End" and if "Friday Start" is greater than "Friday End", even by a minute, I want the notification to appear and to stop the user saving the record.

Also, of course, I want this for all the datacard pairs, so "Monday Start" vs "Monday End", "Tuesday Start" vs "Tuesday End" etc.

 

Any guidance would be greatly appreciated.

Thanks very much,

Garry

Categories:
I have the same question (0)
  • CNT Profile Picture
    10,921 Super User 2024 Season 1 on at

    @GarryPope Place this code in the OnSelect of the Save icon (remember to change control names as required),

    With({
    	varMondayStart:DateTimeValue(crdMondayStartDate.SelectedDate & " " & crdMondayStartHour.SelectedText & " " & crdMondayStartMinute.SelectedText),
    	varMondayEnd:DateTimeValue(crdMondayEndDate.SelectedDate & " " & crdMondayEndHour.SelectedText & " " & crdMondayEndMinute.SelectedText),
    	varTuesdayStart:DateTimeValue(crdTuesdayStartDate.SelectedDate & " " & crdTuesdayStartHour.SelectedText & " " & crdTuesdayStartMinute.SelectedText),
    	varTuesdayEnd:DateTimeValue(crdTuesdayEndDate.SelectedDate & " " & crdTuesdayEndHour.SelectedText & " " & crdTuesdayEndMinute.SelectedText)
    	// Add variables for other days here
    	},
    	If(
    		DateDiff(varMondayStart, varMondayEnd, Minutes)<0 ||
    		DateDiff(varTuesdayStart, varTuesdayEnd, Minutes)<0 ||
    		// Add comparisions for other days here
    		, Notify("ERROR MESSAGE"),
    		// Save the data
    	)
    )

     

  • CU01081947-0 Profile Picture
    716 on at

    Hello @CNT,

    Thank you so much for your quick response, I really appreciate it. I don't doubt it's not working, but when I try it, I'm getting errors. I'm terrible with variables. Leave it with me, and once again, thanks for your reply.

    Garry

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

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 325 Most Valuable Professional

#2
11manish Profile Picture

11manish 165

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 88 Super User 2026 Season 1

Last 30 days Overall leaderboard