Custom Template. Help!

Started by stephock, August 08, 2021, 03:31:58 PM

Previous topic - Next topic

stephock

I have many scanned photographs in my database, of these, many have no original date, many have the year, and many are fully dated.

I have dated these files as follows: undated = 1700/01/01 and where the year is known = YYYY/01/01.

I have written a custom template based on File.DateTime|format which displays 'No Date' for 1700/01/01, and just the year for other dates:

{File.DateTime|format:YYYY/MM/DD;datecomp:eq,1700/01/01,NoDate,{File.DateTime|format:YYYY}}

What I want is to add another condition such that if the MM/DD is anything other than 01/01, the complete date is printed out, but I am not sure how to read just the MM/DD part of the File.DateTime to base the conditional clause on (i.e. 01/01 prints out just the year, any other values for MM/DD prints out the whole date). I've tried using a substring of File.Datetime, but I cannot work out how to make it into a conditional...

If I have made myself clear (!), can anybody help?

Thank you.   

Mario

#1
If {File.DateTime|format:YYYY/MM/DD} returns 1700/06/01

then {File.DateTime|format:YYYY/MM/DD;substr:5,5} returns 06/01

See substr:Start,Length in the help for details.

You can combine this with a function like is:Value,TV,FV,case to output text (or variables) based on the existing date.

Use the VarToy app to test your expression. Follow the link above for examples and documentation.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

stephock

Thanks for that, Mario. Set me on the right track!

stephock

In case anyone is interested, I came up with an even simpler way of doing what I wanted:

{File.DateTime|contains:/1700,No Date,{File.DateTime|contains:01/01,{File.DateTime|format:YYYY},{File.DateTime|format:XWD} {File.DateTime|format:DD/MM/YYYY},},}

If the date is 01/01/1700, it shows as 'No Date';
If the date is 01/01/YYYY. it show only the year;
And if the date is anything else, it shows the whole date.

The screen dump shows one of each, with the actual datetime under the picture.

Once again, Mario, thanks for your help and advice.


Mario

-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

PandDLong


+1

Thanks for posting the solution.