cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
TickboxPhil
Advocate IV
Advocate IV

DateTimeFormat.ShortTime24 still shows ugly long datetime

I have a SQL DateTimeOffset field (yes, I converted them to this handy international SQL datatype as suggested for Power Apps in Working with date/time values and SQL Server | Microsoft Power Apps).

 

We need to show times without their dates, eg "17:45", however for some reason the Power Apps Format on Text Input control of DateTimeFormat.ShortTime24 still shows the ugly underlying long datetime, like "30/12/1899 17:45". This is nasty and very confusing to users. I thought the whole point of ShortTime24 would be exactly what is says. There's no good in using the Time() function because that's just for converting Text, whereas we do have the correct underlying datatype (so it causes an error).

 

Naturally, this applied to the standard SQL DateTime datatype as well as newer DateTimeOffset, so no fix there.

 

Is this a bug / unimplemented functionality, or am I missing something? What is the best practice for showing and editing short Times which can be patched back to the database?

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User III
Super User III

@TickboxPhil 

Can you share the formula you are currently using for the Text function?

In general, you can format dates and times in ANY way that you want.  The built in formats are there for your convenience, but you can always apply any format you want.

So, if you just want the short time only and not the short time (by the way "30/12/1899 17:45" is short date and short time), then you can always do the text format you want:  Text(yourColumn, "hh:mm")

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

2 REPLIES 2
RandyHayes
Super User III
Super User III

@TickboxPhil 

Can you share the formula you are currently using for the Text function?

In general, you can format dates and times in ANY way that you want.  The built in formats are there for your convenience, but you can always apply any format you want.

So, if you just want the short time only and not the short time (by the way "30/12/1899 17:45" is short date and short time), then you can always do the text format you want:  Text(yourColumn, "hh:mm")

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

Thanks @RandyHayes - I'm not using anything for the Text function yet, was expecting the DateTimeFormat.ShortTime24 to do the job and format the underlying datatype value. But it doesn't - however reading Show text, dates, and times in a canvas app - Power Apps | Microsoft Docs closer it looks like it mainly applies to the Text property of a Label, not this Text Input control. As the property is actually available to the Text Input control too, it should be applied and not show the whole underlying SQL DateTime, but seems to be overridden and will leave that for now.

 

So, your idea of applying Text(yourColumn, "hh:mm") does work nicely even on the Text Input control - brilliant, and is the accepted answer here. What's great is that it also applies to the edit and patch as well as display, so when the user goes into it, they don't even see the underlying date part of the DateTime. Phew!

 

Taking this further, I can see a few issues with the DateTimeOffset between PA and SQL, a great idea and will test that further but am currently reverting back to non-offsets. In fact, this was a legacy database pre-SQL Server 2008 and that later release included the Time datatype (I wish we had that 2 decades ago where we had to use integers for timesheet apps instead), so I'm now converting over to those in the backend on new Azure SQL DB. Your suggestion remains a key tool in making any DateTime/Offsets work in Power Apps, overriding the DateTimeFormat. Many thanks!

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Users online (1,370)