Page 2 of 2

Re: Age based on minutes

Posted: 04 Nov 2018 08:49
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.

Re: Age based on minutes

Posted: 04 Nov 2018 09:26
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";

Re: Age based on minutes

Posted: 04 Nov 2018 15:03
by RalphM
...and there we go with the ugliness as stated earlier.

Re: Age based on minutes

Posted: 04 Nov 2018 15:07
by highend
He asked for a sortable way and this kind is the only thing that works *sigh*
Format it differently if you like...

Re: Age based on minutes

Posted: 04 Nov 2018 15:09
by klownboy
Hey highend, nice use of compound assignment operators. :tup:

Re: Age based on minutes

Posted: 04 Nov 2018 15:10
by highend
Hey highend, nice use of compound assignment operators.
We got them, let's use them :ninja:

Re: Age based on minutes

Posted: 04 Nov 2018 15:24
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.

Re: Age based on minutes

Posted: 04 Nov 2018 15:25
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

Re: Age based on minutes

Posted: 04 Nov 2018 15:30
by highend
And how exactly should these entries look like?

Re: Age based on minutes

Posted: 04 Nov 2018 15:39
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:

Re: Age based on minutes

Posted: 04 Nov 2018 15:43
by highend
Show real world examples and don't try to explain concepts...

Re: Age based on minutes

Posted: 04 Nov 2018 15:49
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.