UI Only field to show HH:MM from datetime field

  • 2
  • Question
  • Updated 1 year ago
  • Answered
What formula is required in a UI Only field to turn a datetime into something that appears as HH:MM. 

For example, my datetime field is currently showing a full date/time e.g. "14/07/2016 09:07" but I want to see just "09:07". The Hour and Minute function work to an extent, though I'm losing a 0 at the end, so "09:00" shows as "9:0".

Ideally we'd append a text field "Subject" to the end:

{{StartDateTime}} {{Subject}}

What formula is needed to turn this into:

{{HH:MM}} {{Subject text here}}
Photo of Dan B

Dan B

  • 442 Points 250 badge 2x thumb

Posted 2 years ago

  • 2
Photo of Dave

Dave

  • 5,538 Points 5k badge 2x thumb
Not sure, But i do not think you can accomplish this with UI-only formulas
But probably can do it with Javascript (not my forte)

But it is doable in Salesforce directly

Either using a Formula Field , but you may have issues with local timezones timezone: here

Or you can try using Apex: Here

Good luck
(Edited)
Photo of Dan B

Dan B

  • 442 Points 250 badge 2x thumb
Thanks for comment Dave, I was really hoping Skuid could do some of this as UI fields are powerful and Skuid already seems to know how to stay in correct time zone etc. Took a look at links, will review doing in Salesforce as next solution - though idea of doing this direct is Skuid is appealing so keen to see if anyone has any good ideas first!
Photo of Dave

Dave

  • 5,538 Points 5k badge 2x thumb
You Probably will be able using Javascript + UI-only field, wish i could help there, but i'm a JS noob

In case you are familiar with JS, here's a good starting point: http://help.skuid.com/m/11720/l/129505-skuid-time

And here's a post for a case where they wanted to add 1h to a date/time field, just for you to see syntax example...https://community.skuid.com/skuid/topics/how-to-add-1-hour-to-a-datetime-feild-in-multiple-actions

Hope it helps
(Edited)
Photo of Dan B

Dan B

  • 442 Points 250 badge 2x thumb
In my UI-Only field (formula, text), I found a function FORMAT_TIME:

FORMAT_TIME("HH:mm",{{StartDateTime}})

Looks to work fine, is returning "09:30" for an event with a start time of 9:30am.
Photo of Rich Slack

Rich Slack

  • 4,134 Points 4k badge 2x thumb
Additional Info:
"H:mm" show just 1 or 2 digits as needed for the hours but is in military time. 
"H:mm a" shows 9:30 am or pm

But times are showing as military time.  14:30 pm.  Any good trickes to make it be 2:30 pm?
Photo of Nosayaba Osai

Nosayaba Osai

  • 156 Points 100 badge 2x thumb
If you make the hour lower case, it puts it in the 12 hour format. So you'd do "hh:mm" if you want the leading zero for 02:30 or  "h:mm" for 2:30. Include the "a" if you want the am and pm.
Photo of Rich Slack

Rich Slack

  • 4,134 Points 4k badge 2x thumb
Thank you!