Age based on minutes

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Bart
Posts: 96
Joined: 05 Feb 2017 14:29

Re: Age based on minutes

Post by Bart »

Yes, this is a different approach.

Is there a way to order it in age by clicking on the column header, even though I am able to do so with a neighboring column?
It now orders based on the digit no matter the period name.
Highend outside this forum

highend
Posts: 15004
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Age based on minutes

Post by highend »

Code: Select all

$mins = datediff(property("#date.m", <cc_item>), , "n");
    $days = regexreplace($mins / 1440, "[.,]\d+$");
    if ($days != 0) { $mins -= $days * 1440; }
    $hours = regexreplace($mins / 60, "[.,]\d+$");
    if ($hours != 0) { $mins -= $hours * 60; }
    return format($days, "0000") . ":" . format($hours, "00") . ":" . format($mins, "00") . " d/h/m";
One of my scripts helped you out? Please donate via Paypal

RalphM
Posts: 2122
Joined: 27 Jan 2005 23:38
Location: Cairns, Australia

Re: Age based on minutes

Post by RalphM »

...and there we go with the ugliness as stated earlier.
Ralph :)
(OS: W11 25H2 Home x64 - XY: Current x64 beta - Office 2024 64-bit - Display: 1920x1080 @ 125%)

highend
Posts: 15004
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Age based on minutes

Post by highend »

He asked for a sortable way and this kind is the only thing that works *sigh*
Format it differently if you like...
One of my scripts helped you out? Please donate via Paypal

klownboy
Posts: 4469
Joined: 28 Feb 2012 19:27
Location: Windows 11, 25H2 Build 26200.8737 at 100% 2560x1440

Re: Age based on minutes

Post by klownboy »

Hey highend, nice use of compound assignment operators. :tup:

highend
Posts: 15004
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Age based on minutes

Post by highend »

Hey highend, nice use of compound assignment operators.
We got them, let's use them :ninja:
One of my scripts helped you out? Please donate via Paypal

RalphM
Posts: 2122
Joined: 27 Jan 2005 23:38
Location: Cairns, Australia

Re: Age based on minutes

Post by RalphM »

highend wrote: 04 Nov 2018 15:07 He asked for a sortable way and this kind is the only thing that works *sigh*
Format it differently if you like...
I'm fully aware that the ugliness is needed here in order to make the column sortable - as I pointed out in an earlier post.

I don't need this myself just trying to help as you are and I'm quite happy with regular date columns (sortable however I want) and if I need an interpretation in weeks, days hours... I hover the date of interest to see exactly this and more in the tooltip that pops up.
Ralph :)
(OS: W11 25H2 Home x64 - XY: Current x64 beta - Office 2024 64-bit - Display: 1920x1080 @ 125%)

Bart
Posts: 96
Joined: 05 Feb 2017 14:29

Re: Age based on minutes

Post by Bart »

Is there a way to combine the two solutions that were given.

To make ordering working using the last code by Highend, but it shows sec(s), min(s), hour(s), day(s), week(s) in the list, the code given by Highend in the message before.

Bart
Highend outside this forum

highend
Posts: 15004
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Age based on minutes

Post by highend »

And how exactly should these entries look like?
One of my scripts helped you out? Please donate via Paypal

Bart
Posts: 96
Joined: 05 Feb 2017 14:29

Re: Age based on minutes

Post by Bart »

Using your last code to get the age and if it falls in a range then mention: if less than a minute mention the seconds, otherwise if less than an hour mention the minutes, etc. You think this logic is workable?

This is a sample from the format Age:
To see the attached files, you need to log into the forum.
Last edited by Bart on 04 Nov 2018 15:46, edited 1 time in total.
Highend outside this forum

highend
Posts: 15004
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Age based on minutes

Post by highend »

Show real world examples and don't try to explain concepts...
One of my scripts helped you out? Please donate via Paypal

Bart
Posts: 96
Joined: 05 Feb 2017 14:29

Re: Age based on minutes

Post by Bart »

Well, exactly how it is shown using the code that I gave in one of my last posts but with the ability to order it using the column header.
Highend outside this forum

Post Reply