Skip to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Converting decimal values into proper time format

Featured Replies

I have a calculation field that sums time from a portal. Because the portal defines time units in decimals, so does my calc field but I need it to convert the decimals into proper format: hh:mm:ss (ex. 1.75 hours needs to show up as 01:45:00)

My current code:

Sum ( Time Sheet::Hours ) 

 

Time is in seconds. Assuming your sum is a time field, multiply it by 3600.

  • Author

Thanks, that does it.

...would you know how to pad the hours with a leading zero? Currently it displays as 1:45:00, I'd rather have it as 01:45:00

1 minute ago, McScripta said:

how to pad the hours with a leading zero?

You have that option when you format the field using the Inspector.

  • Author

I actually need this field as one to export to tab-separated text therefore I have to have the padding in raw value of the field itself...

.tab files don't themselves require any 'padding' - the tab provides the field separation.

The end consumer of the file may require two digit hours - you'll need to have another calc field to perform the padding before export in that case.

  • Author
2 minutes ago, webko said:

The end consumer of the file may require two digit hours - you'll need to have another calc field to perform the padding before export in that case.

yes, that is my case. I was hoping that the padding could be rolled into the same calculation I'm already performing

Sum ( Time Sheet::Hours ) * 3600

 

11 minutes ago, McScripta said:

I actually need this field as one to export to tab-separated text therefore I have to have the padding in raw value of the field itself...

No, you don't have to do that. You can format the field on the layout to use a leading zero for hours, and check the "Apply current layout's data formatting..." option when exporting.

That's the easiest way - but if you don't want to put the field on the layout, you can make your calculation =

Let (
t = Sum ( Time Sheet::Hours ) * 3600
;
SerialIncrement ( "00" ; Hour ( t ) ) & SerialIncrement ( ":00" ; Minute ( t ) ) & SerialIncrement ( ":00" ; Seconds ( t ) )
)

 

 

Edited by comment

I'd do it comment's way too. But just FYI here's how you do that type of padding:

Right ( 0 & yourTimeCalc ; 8 )

  • Author
12 minutes ago, comment said:

No, you don't have to do that. You can format the field on the layout to use a leading zero for hours, and check the "Apply current layout's data formatting..." option when exporting.

...that doesn't seem to do it. My field is type Calculation with calculation result set to Time

12 minutes ago, McScripta said:

...that doesn't seem to do it.

Please describe exactly what happens when you try it.

 

 

Edited by comment

22 minutes ago, comment said:

You can format the field on the layout to use a leading zero for hours, and check the "Apply current layout's data formatting..." option when exporting.

And once again, I learn something, which is a great thing for any day... Thanks

  • Author
10 minutes ago, comment said:

Please describe exactly what happens when you try it.

Please disregard, crossed posts. That was in regards to your earlier suggestion about applying current formatting on export.

This worked perfectly:

Let (
t = Sum ( Time Sheet::Hours ) * 3600
;
SerialIncrement ( "00" ; Hour ( t ) ) & SerialIncrement ( ":00" ; Minute ( t ) ) & SerialIncrement ( ":00" ; Seconds ( t ) )
)

Thanks all for pitching in and your help!

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.