* Using Function YEAR with Source Templates

Questions regarding use of any Version of Family Historian. Please ensure you have set your Version of Family Historian in your Profile. If your question fits in one of these subject-specific sub-forums, please ask it there.
Post Reply
avatar
Medows
Gold
Posts: 16
Joined: 16 May 2016 12:28
Family Historian: V7

Using Function YEAR with Source Templates

Post by Medows » 03 Mar 2023 21:05

I have a source template definition which has a date field and I want to use the year of the date field to populate the Footnote and Record Title formats..
My goal is to call the footnote, for example, "PR Burial, 1876, Ide William". The year appears in a death date in this source template.
I checked the FH7 User Manual and implied that I could set up a line like this but it is not displaying any field at all...

{=LeftText(["{author}"],3)} If used in a context in which {author} is a valid field code, this function will return the leftmost 3 letters of the author's name.

So I set up my line like this...
Burial, {=Year(["{Date_of_burial}"])}, {surname} {given_name}

Date of burial --> {Date_of_burial} --> Date

Has anybody got any ideas please?
Alan

avatar
Peter Collier
Famous
Posts: 191
Joined: 04 Nov 2015 17:32
Family Historian: V7
Location: Worcestershire, UK

Re: Using Function YEAR with Source Templates

Post by Peter Collier » 03 Mar 2023 21:19

I use the following for the title in a source record for electoral roll entries:

Record Title Format: {Date:YEAR} electoral roll - {LGA}, {Ward}

Where Date is a defined date field and LGA and Ward are defined text fields in my source template.
Peter Collier

Collier, Savory, Buckerfield, Edmonds, Low, Dungey, Lester, Chambers, Walshe, Moylan, Bradley, Connors, Udale, Wilson, Benfield, Downey

avatar
Peter Collier
Famous
Posts: 191
Joined: 04 Nov 2015 17:32
Family Historian: V7
Location: Worcestershire, UK

Re: Using Function YEAR with Source Templates

Post by Peter Collier » 03 Mar 2023 21:27

Also, if you want to save the effort of having separate fields for surname and given names, you can just define a single name field and use "REVERSE" to have the surname first when you need that. for example, {Name} would output William Idle and {Name:REVERSE} would output Idle, William.
Peter Collier

Collier, Savory, Buckerfield, Edmonds, Low, Dungey, Lester, Chambers, Walshe, Moylan, Bradley, Connors, Udale, Wilson, Benfield, Downey

avatar
Medows
Gold
Posts: 16
Joined: 16 May 2016 12:28
Family Historian: V7

Re: Using Function YEAR with Source Templates

Post by Medows » 04 Mar 2023 15:12

:D Thank you Peter. That worked perfectly. Looks like I tried to make it harder than it was. Are there any good places to read up on how to use some of these functions?
Alan

User avatar
tatewise
Megastar
Posts: 27074
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: Using Function YEAR with Source Templates

Post by tatewise » 04 Mar 2023 15:49

Yes, see the FHUG Knowledge Base articles listed below and their links to FH Help documentation.
Understanding Expressions
Understanding Data References where the :YEAR qualifier is mentioned.
Understanding Functions where the =Year(...) function is mentioned.

BTW: Theoretically, the {=Year(["{Date_of_burial}"])} function should work in Source Template Definitions but I also could not get it to display anything. Maybe it is a bug that should be reported to CP via http://www.calico-pie.com/osticket/open.php.
The other functions such as =Month(...) and =Day(...) also do not work and the qualifiers such as :DAY and :MONTH_NUMBER are also not allowed in Source Template Definitions.
However, the alternative form using Data Ref such as {=Day(%SOUR.~DT-DATE%)} {%SOUR.~DT-DATE:DAY%} work fine.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

User avatar
Mark1834
Megastar
Posts: 2145
Joined: 27 Oct 2017 19:33
Family Historian: V7
Location: South Cheshire, UK

Re: Using Function YEAR with Source Templates

Post by Mark1834 » 04 Mar 2023 18:50

I think it is a general issue with using field codes in functions. I use the TextPart() function in my templates to remove unnecessary elements from {Location} fields, but I could only get it to work using the long form %SOUR.~PL-LOCATION%.

I suspect FH is working as designed, but the help should say that field codes cannot be used as function arguments (if indeed that is the case).
Mark Draper

User avatar
tatewise
Megastar
Posts: 27074
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: Using Function YEAR with Source Templates

Post by tatewise » 04 Mar 2023 19:08

But as Alan says, the Help gives the example of {=LeftText(["{author}"],3)} which works!
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

Post Reply