Page 1 of 1
Show Age and Dates simultaneously in Created & Modified Columns
Posted: 07 Dec 2017 19:50
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
Re: Show Age and Dates simultaneously in Created & Modified Columns
Posted: 07 Dec 2017 20:14
by highend
You can't. You would need to create (and script it) a custom column to do this...
Re: Show Age and Dates simultaneously in Created & Modified Columns
Posted: 07 Dec 2017 20:34
by manmeetbhangu
Hi
Anyone - please advice if you have created such a script. I am not great at scripting.
Regards
MB
Re: Show Age and Dates simultaneously in Created & Modified Columns
Posted: 07 Dec 2017 22:35
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";
Re: Show Age and Dates simultaneously in Created & Modified Columns
Posted: 07 Dec 2017 23:01
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
Re: Show Age and Dates simultaneously in Created & Modified Columns
Posted: 07 Dec 2017 23:26
by highend
There are dozens of postings that describe how a custom column with a script is setup...