cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
seadude
Level 10

Compare two times

Hello, 

 

I'm using the example here: https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/show-text-dates-times#calculate-times-b... however, I don't want my users to use 24hr clock. They need to use 12hr clock for ease and familiarity. 

 

Does anyone have pointers for comparing two times using 12hr clock? 

 

Thank you

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Compare two times

It depends on the Date (or time)  Field type.

If it is defined as Date or DateTime, then we could compare it directly with the DateDiff() function, and use the Text() function to format it into the 12 hour format.

For example:

DateTimeFormat.LongDateTime Full year, month, day of the month, and day of the week, plus hour (12-hour clock), minutes, seconds, and AM/PM designation. The names of the month and the day of the week aren't abbreviated.
DateTimeFormat.ShortDateTime Four-digit year with two-digit month and day of the month, plus hour (12-hour clock), minutes, seconds, and AM/PM designation.

See

Text function in PowerApps

Example:

29.PNG

 

If the date field is defined in Text format, we need to convert the Date text into DateValue or DateTimeValue first, after that, use the DateDiff() to compare the two values.

DateValue, TimeValue, and DateTimeValue functions in PowerApps

 

For the other date and time functions, see:

DateAdd, DateDiff and TimeZoneOffset functions in PowerApps

 

Regards,

Michael

Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
Community Support Team
Community Support Team

Re: Compare two times

It depends on the Date (or time)  Field type.

If it is defined as Date or DateTime, then we could compare it directly with the DateDiff() function, and use the Text() function to format it into the 12 hour format.

For example:

DateTimeFormat.LongDateTime Full year, month, day of the month, and day of the week, plus hour (12-hour clock), minutes, seconds, and AM/PM designation. The names of the month and the day of the week aren't abbreviated.
DateTimeFormat.ShortDateTime Four-digit year with two-digit month and day of the month, plus hour (12-hour clock), minutes, seconds, and AM/PM designation.

See

Text function in PowerApps

Example:

29.PNG

 

If the date field is defined in Text format, we need to convert the Date text into DateValue or DateTimeValue first, after that, use the DateDiff() to compare the two values.

DateValue, TimeValue, and DateTimeValue functions in PowerApps

 

For the other date and time functions, see:

DateAdd, DateDiff and TimeZoneOffset functions in PowerApps

 

Regards,

Michael

Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Super User
Super User

Re: Compare two times

Hello @v-micsh-msft. I'm revisiting this issue and having troubles. 

 

* The Sharepoint list I'm using as a source is a "Date column with Time"

* This renders in PowerApps automatically as: 

2018-05-18_14-45-16.png

2018-05-18_14-45-16.png

 

2018-05-18_14-45-16.png

 

Text(incident_date.SelectedDate & incident_hour.Selected.Value & incident_minute.Selected.Value,ShortDateTime)

 

DateDiff didn't like that option. Any other leads on what I could try or should I try a different approach? 


Thank you

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 (4,756)