JenniferMurphy
Well-known Member
- Joined
- Jul 23, 2011
- Messages
- 2,676
- Office Version
- 365
- Platform
- Windows
I would like to be able to format a time value so that it is displayed in the smallest units that are less than "1" of the next larger unit. That is, use seconds up to 1 minute, then minutes up to 1 hour, hours up to 1 day, etc. I would also like to be able to specify the number of decimal points to display, which complicates things.
Here are some examples:
[TABLE="class: grid, width: 304"]
<tbody>[TR]
[TD="align: center"]C/R
[/TD]
[TD="align: center"]A[/TD]
[TD="align: center"]B[/TD]
[TD="align: center"]C[/TD]
[TD="align: center"]D[/TD]
[/TR]
[TR]
[TD="align: center"]1[/TD]
[TD="align: center"]Value[/TD]
[TD="align: center"]Units[/TD]
[TD="align: center"]DP[/TD]
[TD="align: center"]Result[/TD]
[/TR]
[TR]
[TD="align: center"]2[/TD]
[TD="align: center"]1.75[/TD]
[TD="align: center"]sec[/TD]
[TD="align: center"]0[/TD]
[TD]2 secs
[/TD]
[/TR]
[TR]
[TD="align: center"]3[/TD]
[TD="align: center"]1.75[/TD]
[TD="align: center"]sec[/TD]
[TD="align: center"]1[/TD]
[TD]1.8 secs[/TD]
[/TR]
[TR]
[TD="align: center"]4[/TD]
[TD="align: center"]59.49[/TD]
[TD="align: center"]sec[/TD]
[TD="align: center"]1[/TD]
[TD]59.5 secs[/TD]
[/TR]
[TR]
[TD="align: center"]5[/TD]
[TD="align: center"]59.50[/TD]
[TD="align: center"]sec[/TD]
[TD="align: center"]1[/TD]
[TD]59.5 secs[/TD]
[/TR]
[TR]
[TD="align: center"]6[/TD]
[TD="align: center"]59.50[/TD]
[TD="align: center"]sec[/TD]
[TD="align: center"]0[/TD]
[TD]1 mins[/TD]
[/TR]
[TR]
[TD="align: center"]7[/TD]
[TD="align: center"]59.95[/TD]
[TD="align: center"]sec
[/TD]
[TD="align: center"]2[/TD]
[TD]59.95 secs[/TD]
[/TR]
[TR]
[TD="align: center"]8[/TD]
[TD="align: center"]59.95[/TD]
[TD="align: center"]sec[/TD]
[TD="align: center"]1[/TD]
[TD]1 mins[/TD]
[/TR]
[TR]
[TD="align: center"]9[/TD]
[TD="align: center"]23.49[/TD]
[TD="align: center"]hour[/TD]
[TD="align: center"]1[/TD]
[TD]23.5 hours[/TD]
[/TR]
[TR]
[TD="align: center"]10[/TD]
[TD="align: center"]23.49[/TD]
[TD="align: center"]hour[/TD]
[TD="align: center"]0[/TD]
[TD]23 hours[/TD]
[/TR]
[TR]
[TD="align: center"]11[/TD]
[TD="align: center"]23.50[/TD]
[TD="align: center"]hour[/TD]
[TD="align: center"]1[/TD]
[TD]23.5 hours[/TD]
[/TR]
[TR]
[TD="align: center"]12[/TD]
[TD="align: center"]23.50[/TD]
[TD="align: center"]hour[/TD]
[TD="align: center"]0[/TD]
[TD]1 days[/TD]
[/TR]
</tbody>[/TABLE]
I started writing a UDF, but it quickly got complicated. Is there an easy way to do this?
If not, I'll post my UDF if I ever get it working.
Here are some examples:
[TABLE="class: grid, width: 304"]
<tbody>[TR]
[TD="align: center"]C/R
[/TD]
[TD="align: center"]A[/TD]
[TD="align: center"]B[/TD]
[TD="align: center"]C[/TD]
[TD="align: center"]D[/TD]
[/TR]
[TR]
[TD="align: center"]1[/TD]
[TD="align: center"]Value[/TD]
[TD="align: center"]Units[/TD]
[TD="align: center"]DP[/TD]
[TD="align: center"]Result[/TD]
[/TR]
[TR]
[TD="align: center"]2[/TD]
[TD="align: center"]1.75[/TD]
[TD="align: center"]sec[/TD]
[TD="align: center"]0[/TD]
[TD]2 secs
[/TD]
[/TR]
[TR]
[TD="align: center"]3[/TD]
[TD="align: center"]1.75[/TD]
[TD="align: center"]sec[/TD]
[TD="align: center"]1[/TD]
[TD]1.8 secs[/TD]
[/TR]
[TR]
[TD="align: center"]4[/TD]
[TD="align: center"]59.49[/TD]
[TD="align: center"]sec[/TD]
[TD="align: center"]1[/TD]
[TD]59.5 secs[/TD]
[/TR]
[TR]
[TD="align: center"]5[/TD]
[TD="align: center"]59.50[/TD]
[TD="align: center"]sec[/TD]
[TD="align: center"]1[/TD]
[TD]59.5 secs[/TD]
[/TR]
[TR]
[TD="align: center"]6[/TD]
[TD="align: center"]59.50[/TD]
[TD="align: center"]sec[/TD]
[TD="align: center"]0[/TD]
[TD]1 mins[/TD]
[/TR]
[TR]
[TD="align: center"]7[/TD]
[TD="align: center"]59.95[/TD]
[TD="align: center"]sec
[/TD]
[TD="align: center"]2[/TD]
[TD]59.95 secs[/TD]
[/TR]
[TR]
[TD="align: center"]8[/TD]
[TD="align: center"]59.95[/TD]
[TD="align: center"]sec[/TD]
[TD="align: center"]1[/TD]
[TD]1 mins[/TD]
[/TR]
[TR]
[TD="align: center"]9[/TD]
[TD="align: center"]23.49[/TD]
[TD="align: center"]hour[/TD]
[TD="align: center"]1[/TD]
[TD]23.5 hours[/TD]
[/TR]
[TR]
[TD="align: center"]10[/TD]
[TD="align: center"]23.49[/TD]
[TD="align: center"]hour[/TD]
[TD="align: center"]0[/TD]
[TD]23 hours[/TD]
[/TR]
[TR]
[TD="align: center"]11[/TD]
[TD="align: center"]23.50[/TD]
[TD="align: center"]hour[/TD]
[TD="align: center"]1[/TD]
[TD]23.5 hours[/TD]
[/TR]
[TR]
[TD="align: center"]12[/TD]
[TD="align: center"]23.50[/TD]
[TD="align: center"]hour[/TD]
[TD="align: center"]0[/TD]
[TD]1 days[/TD]
[/TR]
</tbody>[/TABLE]
I started writing a UDF, but it quickly got complicated. Is there an easy way to do this?
If not, I'll post my UDF if I ever get it working.