Page 1 of 1
How to return age difference in custom colomn in a certain way
Posted: 04 Oct 2024 14:49
by Schuller
I found this in another post somewhere: return datediff(filetime(<cc_item>, "c"), filetime(<cc_item>, "m"), "m");
How to modify it to return the age expressed exactly as this example only: 2 months 27 days. I don't want any further detail like the word age an on so in the return.
Re: How to return age difference in custom colomn in a certain way
Posted: 04 Oct 2024 14:59
by highend
?
datediff() returns just a number, you would need to write a function that turns it into "words"
Don added the new age() function for exactly that purpose...
Re: How to return age difference in custom colomn in a certain way
Posted: 04 Oct 2024 15:24
by Schuller
Yes, I saw that new age function.
I guess where I'm stuck then and would need help with is the write a function that turns it into "words"
Can you please assist with that
Thanks
Re: How to return age difference in custom colomn in a certain way
Posted: 04 Oct 2024 15:34
by highend
??
age() already returns "words"^^
E.g.: 2 months, 27 days
What's wrong with that?
Re: How to return age difference in custom colomn in a certain way
Posted: 04 Oct 2024 16:15
by Schuller
When configuring the Custom Column, what do I put in the script section then? I've selected age already.
Re: How to return age difference in custom colomn in a certain way
Posted: 04 Oct 2024 16:41
by highend
Code: Select all
return age(datediff(filetime(<cc_item>, "c"), filetime(<cc_item>, "m"), "ms"));
?
Re: How to return age difference in custom colomn in a certain way
Posted: 04 Oct 2024 16:47
by Schuller
That works, Thanks!
Re: How to return age difference in custom colomn in a certain way
Posted: 04 Oct 2024 17:14
by Schuller
Seems like the duration time is off by one month with XY. When using the duration calculator online, I put Jan 1, 2022, for start date and June 30, 2024, for end date and it formulates 2 years, 6 months. With XY calculating the date difference for the exact same time period, I get 2 years, 5 months. Is there something I can do to modify that script to add this extra month?
Re: How to return age difference in custom colomn in a certain way
Posted: 04 Oct 2024 17:15
by Schuller
Re: How to return age difference in custom colomn in a certain way
Posted: 04 Oct 2024 17:37
by highend
No, you would need to calculate it by taking things like leap years & exact length of months into account (if Don can't improve the precision of age() any further or if age() already rounds the result (which I didn't test))...
Re: How to return age difference in custom colomn in a certain way
Posted: 04 Oct 2024 17:52
by Schuller
Yeah, I'm not sure this will work for me then. Hopefully it will be improved in future.
Thanks anyway.
Re: How to return age difference in custom colomn in a certain way
Posted: 04 Oct 2024 18:52
by admin
No, the datediff() function knows everything there is to know about leap years and month lengths. The problem here is the requested resolution of age(), and how the function handles this: currently the reminder is *cropped*, not *rounded*. If you go for full resolution the result of echo age(datediff("2022-01-01", "2024-06-30", "ms"), 7); is this: 2 years, 5 months, 28 days, 7 hrs, 56 mins, 6 secs, 0 ms which would clearly round up to 2 years, 6 months.
I will add an option to round the result, and all will be fine.
Re: How to return age difference in custom colomn in a certain way
Posted: 04 Oct 2024 19:01
by Schuller
Cool, will look out for it.