How to return age difference in custom colomn in a certain way
How to return age difference in custom colomn in a certain way
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.
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
?
Don added the new
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...One of my scripts helped you out? Please donate via Paypal
Re: How to return age difference in custom colomn in a certain way
Yes, I saw that new age function.
I guess where I'm stuck then and would need help with is the
Can you please assist with that
Thanks
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
??
E.g.:
What's wrong with that?
age() already returns "words"^^E.g.:
2 months, 27 daysWhat's wrong with that?
One of my scripts helped you out? Please donate via Paypal
Re: How to return age difference in custom colomn in a certain way
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
Code: Select all
return age(datediff(filetime(<cc_item>, "c"), filetime(<cc_item>, "m"), "ms"));One of my scripts helped you out? Please donate via Paypal
Re: How to return age difference in custom colomn in a certain way
That works, Thanks!
Re: How to return age difference in custom colomn in a certain way
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
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))...
One of my scripts helped you out? Please donate via Paypal
Re: How to return age difference in custom colomn in a certain way
Yeah, I'm not sure this will work for me then. Hopefully it will be improved in future.
Thanks anyway.
Thanks anyway.
Last edited by Schuller on 04 Oct 2024 19:00, edited 1 time in total.
-
admin
- Site Admin
- Posts: 64915
- Joined: 22 May 2004 16:48
- Location: Win8.1, Win10, Win11, all @100%
- Contact:
Re: How to return age difference in custom colomn in a certain way
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
I will add an option to round the result, and all will be fine.
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.
FAQ | XY News RSS | XY X
Re: How to return age difference in custom colomn in a certain way
Cool, will look out for it.
XYplorer Beta Club