Evaluator column help

I create an Evaluator column to know the number of days/hours/months between today and image was taken.

My idea is:

  • If it is a jpg file and if there is a shooting date then...
  • Calculate and display the result

I see this post Concise Time Notation (27d 6h 56m) evaluator tooltip/column, try to adapt it and create this code that display what I want but errors are generated.

<?xml version="1.0"?>
<evalcolumn align="1" attrrefresh="yes" autorefresh="yes" category="image" foldertype="all" graphcol="#ff8000" header="Prise de vue**" keyword="shootingtimecompteur" maxstars="5" namerefresh="yes" reversesort="no" title="Date/heure (prise de vue) (compteur)**" type="0">if ((IsSet(ext)) || (ext=&quot;jpg&quot;))
	if (IsSet(shootingtime))
		seconds = DateDiff(&quot;s&quot;, shootingtime, Now());
		s = seconds Mod 60;
		m = seconds / 60 Mod 60;
		h = seconds / 60 / 60 Mod 24;
		d = seconds / 60 / 60 / 24;
		ss = (d &gt; 0 || s == 0) ? &quot;&quot; : s + &quot;s&quot;;
		mm = (m == 0) ? &quot;&quot; : m + &quot;m &quot;;
		hh = (h == 0) ? &quot;&quot; : h + &quot;h &quot;;
		dd = (d == 0) ? &quot;&quot; : d + &quot;j &quot;;
		return Trim(dd + hh + mm + ss);</evalcolumn>

How to delete errors (Erreur à la ligne 4, position 7. Valeur inconnue (6): seconds) ?

2 Likes

You need { after an if statement (and the body of it must be closed with } at the end).

2 Likes

Here the final Evaluator column:

<?xml version="1.0"?>
<evalcolumn align="1" attrrefresh="yes" autorefresh="yes" category="image" foldertype="all" graphcol="#ff8000" header="Date taken" keyword="shootingtimecount" maxstars="5" namerefresh="yes" reversesort="no" title="Date/hour (shootingtime) (count)" type="0">// Calculate the number of days/hours/minutes since the shooting date

if ((!IsSet(ext)) || (ext!=&quot;jpg&quot;)) { return };
	if (!IsSet(shootingtime)) { return };
	{
		seconds = DateDiff(&quot;s&quot;, shootingtime, Now());
		s = seconds Mod 60;
		m = seconds / 60 Mod 60;
		h = seconds / 60 / 60 Mod 24;
		d = seconds / 60 / 60 / 24;
		ss = (d &gt; 0 || s == 0) ? &quot;&quot; : s + &quot;s&quot;;
		mm = (m == 0) ? &quot;&quot; : m + &quot;m &quot;;
		hh = (h == 0) ? &quot;&quot; : h + &quot;h &quot;;
		dd = (d == 0) ? &quot;&quot; : d + &quot;j &quot;;
		return Trim(dd + hh + mm + ss);
	}
</evalcolumn>
1 Like

strangely, I put a { after the first if before the second one and the column also works. no difference? )))

if ((IsSet(ext)) || (ext="jpg"))
	{if (IsSet(shootingtime))
		seconds = DateDiff("s", shootingtime, Now());