Show Age and Dates simultaneously in Created & Modified Columns

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
manmeetbhangu
Posts: 45
Joined: 12 Feb 2014 19:29

Show Age and Dates simultaneously in Created & Modified Columns

Post by manmeetbhangu »

Hi

In the Modified and Created Columns, how can I see the following simultaneously:

Date in a particular notation e.g. 14-Sept-17 6:07:00 PM AND "Show Age" which shows age in notation e.g. 14 days

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

Re: Show Age and Dates simultaneously in Created & Modified Columns

Post by highend »

You can't. You would need to create (and script it) a custom column to do this...
One of my scripts helped you out? Please donate via Paypal

manmeetbhangu
Posts: 45
Joined: 12 Feb 2014 19:29

Re: Show Age and Dates simultaneously in Created & Modified Columns

Post by manmeetbhangu »

Hi

Anyone - please advice if you have created such a script. I am not great at scripting.

Regards
MB

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

Re: Show Age and Dates simultaneously in Created & Modified Columns

Post by highend »

Code: Select all

    $months = "Jan|Feb|Mar|Apr|May|June|July|Aug|Sept|Oct|Nov|Dec";
    $date   = property("#date.c", <cc_item>);
    $age    = datediff($date, , "s");
    if ($age >= 31536000)    { $period = regexreplace($age / 31536000, "[.,].*$") . " year(s)"; }
    elseif ($age >= 2678400) { $period = regexreplace($age / 2678400,  "[.,].*$") . " month(s)"; }
    elseif ($age >= 86400)   { $period = regexreplace($age / 86400,    "[.,].*$") . " day(s)"; }
    elseif ($age >= 3600)    { $period = regexreplace($age / 3600,     "[.,].*$") . " hour(s)"; }
    elseif ($age >= 60)      { $period = regexreplace($age / 60,       "[.,].*$") . " minute(s)"; }
    else { $period = $age . " second(s)"; }
    $token  = formatdate($date, "yy-m-dd-h-nn-ss");
    $month  = gettoken($months, gettoken($token, 2, "-"), "|");
    $hours  = gettoken($token, 4, "-");
    if ($hours == 0 || $hours < 12) { $short = "AM"; }
    else { $short = "PM"; }
    return replace(formatdate($date, "dd-##-yy h:nn:ss"), "##", $month) . " $short | Age $period";
One of my scripts helped you out? Please donate via Paypal

manmeetbhangu
Posts: 45
Joined: 12 Feb 2014 19:29

Re: Show Age and Dates simultaneously in Created & Modified Columns

Post by manmeetbhangu »

highend wrote:

Code: Select all

    $months = "Jan|Feb|Mar|Apr|May|June|July|Aug|Sept|Oct|Nov|Dec";
    $date   = property("#date.c", <cc_item>);
    $age    = datediff($date, , "s");
    if ($age >= 31536000)    { $period = regexreplace($age / 31536000, "[.,].*$") . " year(s)"; }
    elseif ($age >= 2678400) { $period = regexreplace($age / 2678400,  "[.,].*$") . " month(s)"; }
    elseif ($age >= 86400)   { $period = regexreplace($age / 86400,    "[.,].*$") . " day(s)"; }
    elseif ($age >= 3600)    { $period = regexreplace($age / 3600,     "[.,].*$") . " hour(s)"; }
    elseif ($age >= 60)      { $period = regexreplace($age / 60,       "[.,].*$") . " minute(s)"; }
    else { $period = $age . " second(s)"; }
    $token  = formatdate($date, "yy-m-dd-h-nn-ss");
    $month  = gettoken($months, gettoken($token, 2, "-"), "|");
    $hours  = gettoken($token, 4, "-");
    if ($hours == 0 || $hours < 12) { $short = "AM"; }
    else { $short = "PM"; }
    return replace(formatdate($date, "dd-##-yy h:nn:ss"), "##", $month) . " $short | Age $period";
Hi

thank you a lot. I made a text file with the above code and renamed it date_age.xys and pasted in C:\Users\UserName\AppData\Roaming\XYplorer\Scripts\ folder.

Then I selected the file and went to menu > Scripting > Try Script and it shows beautifully step by step ending return value of
07-Dec-17 16:47:47 PM | Age 9 minute(s)

But when I load this script, nothing happens. I even save after loading the script. Can you help me how do I load it and show it as an extra column?

Regards
MB

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

Re: Show Age and Dates simultaneously in Created & Modified Columns

Post by highend »

There are dozens of postings that describe how a custom column with a script is setup...
One of my scripts helped you out? Please donate via Paypal

Post Reply