[Solved] Show number as a fixed fraction
[Solved] Show number as a fixed fraction
I want it to round to nearest 1/12th to show years & months without having the whole date so that 3.5 years shows as 3 6/12.
Thank you.
Thank you.
Last edited by MrProgrammer on Mon Nov 02, 2026 4:34 pm, edited 2 times in total.
Reason: Tagged ✓ [Solved]; Multiple solutions provided and no further questions from Kirjava
Reason: Tagged ✓ [Solved]; Multiple solutions provided and no further questions from Kirjava
OpenOffice 3.1 on Windows 7
Re: Is there a way to show a number as a fixed fraction?
Ended up doing =TRUNC(B2/1)&"y "&ROUNDDOWN(12*(B2-TRUNC(B2/1)))&"m" to show it but there's probably an easier way. I'll write down the easier way and do that next time. This takes 22.4 and spits out 22y 5m.
OpenOffice 3.1 on Windows 7
Re: Is there a way to show a number as a fixed fraction?
Format B2 into Numberformat-code #"y "??/12 "m"
Libreoffice 25.2… on Debian 13 (trixie) (on RaspberryPI5)
Libreoffice 25.8… flatpak on Debian 13 (trixie) (on RaspberryPI5)
Libreoffice 25.8… flatpak on Debian 13 (trixie) (on RaspberryPI5)
Re: Is there a way to show a number as a fixed fraction?
Format > Cells > Fraction > Pasted [ #"y "??/12 "m" ] into the format box > Click OK > No change.
It reverted back to "general" when I checked again.
What did I do wrong?
It reverted back to "general" when I checked again.
What did I do wrong?
OpenOffice 3.1 on Windows 7
Re: Is there a way to show a number as a fixed fraction?
nobody knows… see attached Example with a calculated yearfraction formatted the way you want!
Libreoffice 25.2… on Debian 13 (trixie) (on RaspberryPI5)
Libreoffice 25.8… flatpak on Debian 13 (trixie) (on RaspberryPI5)
Libreoffice 25.8… flatpak on Debian 13 (trixie) (on RaspberryPI5)
Re: Is there a way to show a number as a fixed fraction?
No it is not.
Your example:
08/05/26 End_date
01/02/24 Start_date
2.2657534247 =YEARFRAC(A2;A1;3)
My example:
24.5 24y 5m
Your example:
08/05/26 End_date
01/02/24 Start_date
2.2657534247 =YEARFRAC(A2;A1;3)
My example:
24.5 24y 5m
OpenOffice 3.1 on Windows 7
Re: Is there a way to show a number as a fixed fraction?
Libreoffice 25.2… on Debian 13 (trixie) (on RaspberryPI5)
Libreoffice 25.8… flatpak on Debian 13 (trixie) (on RaspberryPI5)
Libreoffice 25.8… flatpak on Debian 13 (trixie) (on RaspberryPI5)
- MrProgrammer
- Moderator
- Posts: 5480
- Joined: Fri Jun 04, 2010 7:57 pm
- Location: Wisconsin, USA
Re: Is there a way to show a number as a fixed fraction?
Your forum signature gives your environment as OpenOffice 3.1 on Windows 7. I am sure OpenOffice 3.1 would not have supported ??/12 in the number format. I doubt that any OpenOffice version does. So karolus' solution is only for LibreOffice. Read about LibreOffice/OpenOffice comparisons in the Beginners forum.
If this solved your problem please go to your first post use the Edit ✏️ button and add [Solved] to the start of the Subject field. Select the green checkmark icon at the same time.
Mr. Programmer
AOO 4.1.7 Build 9800, MacOS 13.7.8, iMac Intel. The locale for any menus or Calc formulas in my posts is English (USA).
AOO 4.1.7 Build 9800, MacOS 13.7.8, iMac Intel. The locale for any menus or Calc formulas in my posts is English (USA).
- MrProgrammer
- Moderator
- Posts: 5480
- Joined: Fri Jun 04, 2010 7:57 pm
- Location: Wisconsin, USA
Re: Is there a way to show a number as a fixed fraction?
I don't know what that term means.
If you don't know the start/end dates, only the duration (in days), you cannot present this as years and rounded months unless you are willing to ignore the detail that months and years have different lengths. As a simple example, a duration of 15 days is less than half of January but more than half of February. But you could consider years to be divided into twelve equal pieces of 30.436875 days. 15 days is less than half of an average month.
INT(duration/30.436875+.5) is the number of months, rounded.
QUOTIENT(months;12) is the number of full (12-month) years.
MOD(months;12) is the number of months which follow those years.
If you need any additional assistance attach a spreadsheet demonstrating the situation (remove confidential information then use Post Reply, not Quick Reply, and don't attach a picture instead of the spreadsheet itself). I will not help further unless you attach a spreadsheet document.
[Tutorial] Ten concepts that every Calc user should know
If this solved your problem please go to your first post use the Edit ✏️ button and add [Solved] to the start of the Subject field. Select the green checkmark icon at the same time.
Mr. Programmer
AOO 4.1.7 Build 9800, MacOS 13.7.8, iMac Intel. The locale for any menus or Calc formulas in my posts is English (USA).
AOO 4.1.7 Build 9800, MacOS 13.7.8, iMac Intel. The locale for any menus or Calc formulas in my posts is English (USA).
Re: Is there a way to show a number as a fixed fraction?
A variant:
On Windows 10: LibreOffice 25.8.4 and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
---
Lupp from München