[Solved] Userdefined num format for number of days and hours

Discuss the spreadsheet application
Post Reply
JulianR
Posts: 26
Joined: Mon Mar 12, 2018 9:41 am

[Solved] Userdefined num format for number of days and hours

Post by JulianR »

Hi!

I want to make a custom cell format, that will show for a difference of two cells with date-time data as "X days Yh" or just "Yh" if the difference is less than 24 hours and I after some effort, the best effect i get is with this format code:

Code: Select all

[>=2]##" days" "h";[>1]##"day" "h";H "h"
But when I try to insert H between " days " and "h" in the first two conditionals, the formatting stops working and cell stops showing content.
I have attached spread sheet with sample data.

Is there a way to make it work as I need?
Attachments
Days Hours Sample data.ods
(15.38 KiB) Downloaded 65 times
Last edited by JulianR on Fri Mar 22, 2019 9:03 am, edited 1 time in total.
Apache OpenOffice 4.1.1 / LibreOffice 5.3 / LibreOffice 6.0 / LibreOffice 6.2 on Windows 7
User avatar
MrProgrammer
Moderator
Posts: 4895
Joined: Fri Jun 04, 2010 7:57 pm
Location: Wisconsin, USA

Re: User-defined number format for number of days and hours

Post by MrProgrammer »

JulianR wrote:I want to make a custom cell format, that will show for a [duration] as "X days Yh" or just "Yh" if the difference is less than 24 hours. Is there a way to make [my user-defined number format] work as I need?
No. Read section 4. Times in cells in Ten concepts that every Calc user should know.
You can display duration as days plus hours by using multiple cells or by using a formula which creates a text result.

If this solved your problem please go to your first post use the Edit button and add [Solved] to the start of the title. You can select the green checkmark icon at the same time.
Mr. Programmer
AOO 4.1.7 Build 9800, MacOS 13.6.3, iMac Intel.   The locale for any menus or Calc formulas in my posts is English (USA).
JulianR
Posts: 26
Joined: Mon Mar 12, 2018 9:41 am

Re: User-defined number format for number of days and hours

Post by JulianR »

Thank you. Problem solved.
Apache OpenOffice 4.1.1 / LibreOffice 5.3 / LibreOffice 6.0 / LibreOffice 6.2 on Windows 7
Post Reply