* Source Template Definition
-
Gary_G
- Superstar
- Posts: 304
- Joined: 24 Mar 2023 19:05
- Family Historian: V7
- Location: Calgary, Alberta, Canada
Source Template Definition
"tatewise" regarding Source Template Definition and Generic Type (21739):
I am also addressing a similar issue. I am trying to construct a "Record Title Format" containing a date string. My source template contains a field called "DATE", defined as a "Date" type, and I'd like to cast it in the the format "YYYY-MM-DD".
I don't see that there is a simple function to do this, so I assume that I have to write an expression for this.
Is there somewhere I can find out what sub-structure elements are available for a source template field like the "Date" field and similar? You referred to one, when you mentioned "%SOUR.~DT-YEAR:YEAR%".
I am also addressing a similar issue. I am trying to construct a "Record Title Format" containing a date string. My source template contains a field called "DATE", defined as a "Date" type, and I'd like to cast it in the the format "YYYY-MM-DD".
I don't see that there is a simple function to do this, so I assume that I have to write an expression for this.
Is there somewhere I can find out what sub-structure elements are available for a source template field like the "Date" field and similar? You referred to one, when you mentioned "%SOUR.~DT-YEAR:YEAR%".
Gary Gauthier
Hunting History in the Wild!
Hunting History in the Wild!
- tatewise
- Megastar
- Posts: 27075
- Joined: 25 May 2010 11:00
- Family Historian: V7
- Location: Torbay, Devon, UK
- Contact:
Re: Source Template Definition and Generic Type
Gary, there are two options in that case but both use the FH Help > Generic Topics > Date Formats which define qualifiers for Date fields such as YEAR (as earlier), MONTH_NUMBER, DAY, and ABBREV3 plus others.
1) Use ABBREV3 formatting.
i.e. {%SOUR.~DT-DATE:ABBREV3%}
That will display the current Preferred Short Date Format which is defined in the Tools > Preferences > General tab.
One of its options is yyyy-mm-dd which is exactly what you want.
Just beware that it may affect Date display formats elsewhere and if you change the option it will change your Source Record Title rendering.
2) Use YEAR MONTH_NUMBER DAY formatting.
This requires all three qualifiers to be combined into a single display format with hyphen separators.
e.g. {%SOUR.~DT-DATE:YEAR%}-{%SOUR.~DT-DATE:MONTH_NUMBER%}-{%SOUR.~DT-DATE:DAY%}
This will always display the yyyy-mm-dd format regardless of the Preferred Short Date Format setting.
The only caveat for both methods is that single-digit months and days do NOT display a leading zero so 1 Jan 1900 is 1900-1-1
It is possible to workaround that and include leading zeros but the expression gets much more complex.
1) Use ABBREV3 formatting.
i.e. {%SOUR.~DT-DATE:ABBREV3%}
That will display the current Preferred Short Date Format which is defined in the Tools > Preferences > General tab.
One of its options is yyyy-mm-dd which is exactly what you want.
Just beware that it may affect Date display formats elsewhere and if you change the option it will change your Source Record Title rendering.
2) Use YEAR MONTH_NUMBER DAY formatting.
This requires all three qualifiers to be combined into a single display format with hyphen separators.
e.g. {%SOUR.~DT-DATE:YEAR%}-{%SOUR.~DT-DATE:MONTH_NUMBER%}-{%SOUR.~DT-DATE:DAY%}
This will always display the yyyy-mm-dd format regardless of the Preferred Short Date Format setting.
The only caveat for both methods is that single-digit months and days do NOT display a leading zero so 1 Jan 1900 is 1900-1-1
It is possible to workaround that and include leading zeros but the expression gets much more complex.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
-
Gary_G
- Superstar
- Posts: 304
- Joined: 24 Mar 2023 19:05
- Family Historian: V7
- Location: Calgary, Alberta, Canada
Re: Source Template Definition and Generic Type
Thank you, "tatewise";
First; I don't want to hijack this thread. So; I will start another of this more specific topic and copy the following, if you feel this would be better.
I'm trying to auto-generate a source title that matches my existing filing scheme based upon the contents of what I enter into the fields of a fully "splitter"-style (citation portion only) template.
I've managed to determine how to generate all elements save two; the GEDCOM tag, used to identify the record-type, and the sortable date string.
As you can see, I do actually need to have leading zeros in the date elements. So; any additional suggestions to achieve that goal would be helpful.
I think, based on other posts, I should be able to translate "born|married|died|buried" into the related GEDCOM standard tags that I use as an abbreviation.
As I'm not yet familiar with the underpinnings of FH7, but I note that it looks like it uses a relational database. So; I wonder if it has the concept of stored procedures etc., which would allow one to store a complex function for creating the YYYY-MM-DD element. This is because it is so widely used in sorting dates and you say it would be much more complex that what you posted.
First; I don't want to hijack this thread. So; I will start another of this more specific topic and copy the following, if you feel this would be better.
I'm trying to auto-generate a source title that matches my existing filing scheme based upon the contents of what I enter into the fields of a fully "splitter"-style (citation portion only) template.
As this is a standard format for me, I will need to use your second approach, in order to be independent of the preferred date settings.Genealogy__Bazin_(Calixte_Donatien)__FE__MARR_1829-10-24__001__1-2
I've managed to determine how to generate all elements save two; the GEDCOM tag, used to identify the record-type, and the sortable date string.
As you can see, I do actually need to have leading zeros in the date elements. So; any additional suggestions to achieve that goal would be helpful.
I think, based on other posts, I should be able to translate "born|married|died|buried" into the related GEDCOM standard tags that I use as an abbreviation.
As I'm not yet familiar with the underpinnings of FH7, but I note that it looks like it uses a relational database. So; I wonder if it has the concept of stored procedures etc., which would allow one to store a complex function for creating the YYYY-MM-DD element. This is because it is so widely used in sorting dates and you say it would be much more complex that what you posted.
Gary Gauthier
Hunting History in the Wild!
Hunting History in the Wild!
- tatewise
- Megastar
- Posts: 27075
- Joined: 25 May 2010 11:00
- Family Historian: V7
- Location: Torbay, Devon, UK
- Contact:
Re: Source Template Definition
I've created this new thread for you Gary.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
-
Gary_G
- Superstar
- Posts: 304
- Joined: 24 Mar 2023 19:05
- Family Historian: V7
- Location: Calgary, Alberta, Canada
Re: Source Template Definition
Thank you, "tatewise".
Sometimes a simple question becomes more complex than expected and needs its own thread.
Sometimes a simple question becomes more complex than expected and needs its own thread.
Gary Gauthier
Hunting History in the Wild!
Hunting History in the Wild!
- tatewise
- Megastar
- Posts: 27075
- Joined: 25 May 2010 11:00
- Family Historian: V7
- Location: Torbay, Devon, UK
- Contact:
Re: Source Template Definition
FH does not use a relational database. FH has its own custom data structures (which is why it is so fast) and they are based closely on the GEDCOM data structures. It cannot save processes.
The thread Date format in queries (19020) posed the same problem with this expression as a solution:
=Text(TextIf(%FACT.DATE:DAY% <= 9,Text("0" . Text(%FACT.DATE:DAY%)),Text(%FACT.DATE:DAY%)) . "/" . TextIf(%FACT.DATE:MONTH_NUMBER% <= 9,Text("0" . Text(%FACT.DATE:MONTH_NUMBER%)),Text(%FACT.DATE:MONTH_NUMBER%)) . "/" . Text(%FACT.DATE:YEAR%))
You need to replace "/" with "-" and FACT.DATE with SOUR.~DT-DATE and change the order to produce yyyy-mm-dd.
I'll check to see if it can be further simplified.
The thread Date format in queries (19020) posed the same problem with this expression as a solution:
=Text(TextIf(%FACT.DATE:DAY% <= 9,Text("0" . Text(%FACT.DATE:DAY%)),Text(%FACT.DATE:DAY%)) . "/" . TextIf(%FACT.DATE:MONTH_NUMBER% <= 9,Text("0" . Text(%FACT.DATE:MONTH_NUMBER%)),Text(%FACT.DATE:MONTH_NUMBER%)) . "/" . Text(%FACT.DATE:YEAR%))
You need to replace "/" with "-" and FACT.DATE with SOUR.~DT-DATE and change the order to produce yyyy-mm-dd.
I'll check to see if it can be further simplified.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
-
Gary_G
- Superstar
- Posts: 304
- Joined: 24 Mar 2023 19:05
- Family Historian: V7
- Location: Calgary, Alberta, Canada
Re: Source Template Definition
Thank you, so much, "tatewise!
I had searched and couldn't find anything, but then I don't know my way around the board as you do.
This is such a key code snippet and I will be using it as part of all my templates source names.
I'll be following this thread in case you do find a more elegant method. Since this is to be used in autogenerated source name, I should be able to easily update the template with any further improvement.
I should also note that as a "visual learner", I really find actually seeing such code snippets to incredibly instructive. I can see what is being done and consult the reference material to see why they work. Hopefully; as I see more of them, my questions will be fewer. :>)
I had searched and couldn't find anything, but then I don't know my way around the board as you do.
This is such a key code snippet and I will be using it as part of all my templates source names.
I'll be following this thread in case you do find a more elegant method. Since this is to be used in autogenerated source name, I should be able to easily update the template with any further improvement.
I should also note that as a "visual learner", I really find actually seeing such code snippets to incredibly instructive. I can see what is being done and consult the reference material to see why they work. Hopefully; as I see more of them, my questions will be fewer. :>)
Gary Gauthier
Hunting History in the Wild!
Hunting History in the Wild!
- tatewise
- Megastar
- Posts: 27075
- Joined: 25 May 2010 11:00
- Family Historian: V7
- Location: Torbay, Devon, UK
- Contact:
Re: Source Template Definition
I think this is a simpler expression and rearranged for your yyyy-mm-dd in a Source Template Definition format:
<{Date:YEAR}{=TextIf(%SOUR.~DT-DATE:MONTH_NUMBER% <= 9,"-0","-")}{%SOUR.~DT-DATE:MONTH_NUMBER%}{=TextIf(%SOUR.~DT-DATE:DAY% <= 9,"-0","-")}{%SOUR.~DT-DATE:DAY%}>
The surrounding < angle brackets > are necessary to inhibit space characters between each { bracketed } component.
Otherwise, I suspect you can work out the rest.
<{Date:YEAR}{=TextIf(%SOUR.~DT-DATE:MONTH_NUMBER% <= 9,"-0","-")}{%SOUR.~DT-DATE:MONTH_NUMBER%}{=TextIf(%SOUR.~DT-DATE:DAY% <= 9,"-0","-")}{%SOUR.~DT-DATE:DAY%}>
The surrounding < angle brackets > are necessary to inhibit space characters between each { bracketed } component.
Otherwise, I suspect you can work out the rest.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
-
Gary_G
- Superstar
- Posts: 304
- Joined: 24 Mar 2023 19:05
- Family Historian: V7
- Location: Calgary, Alberta, Canada
Re: Source Template Definition
Thank you, "tatewise".
Yes; I can figure out the rest. I wondered about that approach, but wasn't quite sure how to implement it.
Yes; I can figure out the rest. I wondered about that approach, but wasn't quite sure how to implement it.
Gary Gauthier
Hunting History in the Wild!
Hunting History in the Wild!
Re: Source Template Definition
Mike/Gary...I am also learning from this because I also need the yyyy-mm-dd format.
Thanks, Alan
Thanks, Alan
Re: Source Template Definition
I raised this recently in a pre-existing thread which may be of interest: Re: Including update date in reports
Sarah Bell – Australia
View my tree on Wikitree
View my tree on Wikitree