JenniferMurphy
Well-known Member
- Joined
- Jul 23, 2011
- Messages
- 2,687
- Office Version
- 365
- Platform
- Windows
Is there a function, add-in, or easy way to format time values so that the units displayed vary with the magnitude of the value?
What I mean is that the function will convert the value to the units that will be >1 but less that "1" of the next higher units.
I am looking for something like this where a mythical FmtTime function has this syntax:
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD="align: center"]R/C[/TD]
[TD="align: center"]C[/TD]
[TD="align: center"]D[/TD]
[TD="align: center"]E[/TD]
[TD="align: center"]F[/TD]
[/TR]
[TR]
[TD="align: center"]3[/TD]
[TD="align: center"]Start[/TD]
[TD="align: center"]End[/TD]
[TD="align: center"]Elapsed[/TD]
[TD="align: center"]Formula[/TD]
[/TR]
[TR]
[TD="align: center"]4[/TD]
[TD="align: center"]03/13/19[/TD]
[TD="align: center"]03/19/19[/TD]
[TD="align: right"]6.0 dys[/TD]
[TD="align: center"]E4: =fmttime(D4-C4,"day")[/TD]
[/TR]
[TR]
[TD="align: center"]5[/TD]
[TD="align: center"]02/22/19[/TD]
[TD="align: center"]03/19/19[/TD]
[TD="align: right"]3.6 wks[/TD]
[TD="align: center"]E5: =fmttime(D5-C5,"day")[/TD]
[/TR]
[TR]
[TD="align: center"]6[/TD]
[TD="align: center"]11/02/17[/TD]
[TD="align: center"]03/19/19[/TD]
[TD="align: right"]1.4 yrs[/TD]
[TD="align: center"]E6: =fmttime(D6-C6,"day")[/TD]
[/TR]
[TR]
[TD="align: center"]7[/TD]
[TD="align: center"]07/04/02[/TD]
[TD="align: center"]03/19/19[/TD]
[TD="align: right"]16.7 yrs[/TD]
[TD="align: center"]E7: =fmttime(D7-C7,"day")[/TD]
[/TR]
</tbody>[/TABLE]
I have a crude function that handles years, months, and days, but it has some glitches. I'd like something more general and robust.
Any pointers?
What I mean is that the function will convert the value to the units that will be >1 but less that "1" of the next higher units.
- If the value is less than one minute (60 seconds), it will be formatted as seconds.
- If it is less than 1 hour (60 minutes), it will be formatted as minutes.
- If it less less than 1 day (24 hours), it will be formatted as hours.
- If it is less than 1 week (7 days), it will be formatted as days.
- If it is less than 1 month (12.175 days), it will be formatted as weeks.
- If it is less that 1 year (325.25 days), it will be formatted as months.
- Otherwise, it will be formatted as years.
I am looking for something like this where a mythical FmtTime function has this syntax:
=FmtTime(InValue, InUnits)
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD="align: center"]R/C[/TD]
[TD="align: center"]C[/TD]
[TD="align: center"]D[/TD]
[TD="align: center"]E[/TD]
[TD="align: center"]F[/TD]
[/TR]
[TR]
[TD="align: center"]3[/TD]
[TD="align: center"]Start[/TD]
[TD="align: center"]End[/TD]
[TD="align: center"]Elapsed[/TD]
[TD="align: center"]Formula[/TD]
[/TR]
[TR]
[TD="align: center"]4[/TD]
[TD="align: center"]03/13/19[/TD]
[TD="align: center"]03/19/19[/TD]
[TD="align: right"]6.0 dys[/TD]
[TD="align: center"]E4: =fmttime(D4-C4,"day")[/TD]
[/TR]
[TR]
[TD="align: center"]5[/TD]
[TD="align: center"]02/22/19[/TD]
[TD="align: center"]03/19/19[/TD]
[TD="align: right"]3.6 wks[/TD]
[TD="align: center"]E5: =fmttime(D5-C5,"day")[/TD]
[/TR]
[TR]
[TD="align: center"]6[/TD]
[TD="align: center"]11/02/17[/TD]
[TD="align: center"]03/19/19[/TD]
[TD="align: right"]1.4 yrs[/TD]
[TD="align: center"]E6: =fmttime(D6-C6,"day")[/TD]
[/TR]
[TR]
[TD="align: center"]7[/TD]
[TD="align: center"]07/04/02[/TD]
[TD="align: center"]03/19/19[/TD]
[TD="align: right"]16.7 yrs[/TD]
[TD="align: center"]E7: =fmttime(D7-C7,"day")[/TD]
[/TR]
</tbody>[/TABLE]
I have a crude function that handles years, months, and days, but it has some glitches. I'd like something more general and robust.
Any pointers?