June 3, 2023 - u/Danlat6611 Total Notion noob here - trying to create an asset database for IT equipment, effectively what I want is to see the age of a device when we decommission it from use. I'll show you what I have currently, extensive searching of google and reddit has led me in circles. It shows the amount of days old, I want it to display in the format YY/MM, for example, below I would like it to display as '6y 10mo’
Quick answer
<aside> <img src="https://prod-files-secure.s3.us-west-2.amazonaws.com/9210293a-6b0f-4638-8e8d-3c40b40ed42b/b8366055-a446-4861-aa67-1e926814ca74/Invisible.png" alt="https://prod-files-secure.s3.us-west-2.amazonaws.com/9210293a-6b0f-4638-8e8d-3c40b40ed42b/b8366055-a446-4861-aa67-1e926814ca74/Invisible.png" width="40px" /> Here's my propositions :
Version 1 - Give an age between the Date of Purchase and the Date of Decommissioning. If there is no decommissioning date, it uses the current date.
Create a Years property
dateBetween(prop("Date of Decommissioning") ? prop("Date of Decommissioning") : now(), prop("Date of Purchase"), "years")
Create a Months property
dateBetween(prop("Date of Decommissioning") ? prop("Date of Decommissioning") : now(), dateAdd(prop("Date of Purchase"), prop("Years"), "years"), "months")
Version 2 - Give an age between the Date of Purchase and the Date of Decommissioning. If there is no decommissioning date, the field remains empty.
Create a Years property
dateBetween(prop("Date of Decommissioning"), prop("Date of Purchase"), "years")
Create a Months property
dateBetween(prop("Date of Decommissioning"), dateAdd(prop("Date of Purchase"), prop("Years"), "years"), "months")
Whatever the version
Create a Age property
(prop("Years") ? (format(prop("Years")) + "y ") : "") + (prop("Months") ? (format(prop("Months")) + "mo") : "")
<aside> ℹ️ Why not use a single formula?
Because the "Age" formula requires the "Years" and "Months" properties twice. The "Months" property itself uses the "Years" property once. All in all, putting everything in a single formula would mean performing the same calculation 4 times to determine the years.
</aside>
</aside>
Age between date of purchase and date of decommissioning
By @Ouinx2 - **Buy me a Beer**