* Question about formatting dates entered from templates

Questions about Generic and Templated Sources within FH and their associated Citations and Repositories
Post Reply
avatar
Gary_G
Megastar
Posts: 756
Joined: 24 Mar 2023 19:05
Family Historian: V7

Question about formatting dates entered from templates

Post by Gary_G »

In defining a footnote, I would like to set the access date to the system date, unless the user enters a specific access date in the associated template field. I currently use the code snippet, "<{Access_Date}|{=Today()}>".

Under the default condition this correctly generates "12 Feb 2024", in line with my system defaults. However; if the user enters "11 February 2024" in the template, then that is what appears in the footnote.

I'd like to ensure that the footnote date format always follows the system default, but I am not quite sure how to make this happen.
Current FH7 Date Settings
Current FH7 Date Settings
Screenshot 2024-02-11 at 9.14.22 AM.png (96.17 KiB) Viewed 522 times
Is a format function of some sort required?
Gary Gauthier
Hunting History in the Wild!
User avatar
tatewise
Megastar
Posts: 28488
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: Question about formatting dates entered from templates

Post by tatewise »

Have you tried making the associated template field a Date metafield?

I suspect it may be a Text field.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
avatar
Gary_G
Megastar
Posts: 756
Joined: 24 Mar 2023 19:05
Family Historian: V7

Re: Question about formatting dates entered from templates

Post by Gary_G »

Mike;

It is a Date metafield.

I just noticed Teresa's post; "* Custom citation template question..."
viewtopic.php?t=18532&sid=b2ee1d94fee34 ... ea8f5595c5

That was back in 2020. I think I'm having the same issue. There was a suggestion made to use a text field for the {Access_Date}, but that has its drawbacks. Perhaps there Is a better solution to the issue now?
I really don't mind if the month is abbreviated or shown in full, so long as it's consistent.

I thought I had a solution by using the =Date() function on a referenced version of the {Access_Date}. It worked to ensure that the system default formatted date was displayed, but crashed FH7 when I left the {Access_Date} blank and expected the system-formatted {=Date()} value to be displayed. I'm not familiar enough with calling functions, so perhaps you can suggest something.
Gary Gauthier
Hunting History in the Wild!
User avatar
tatewise
Megastar
Posts: 28488
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: Question about formatting dates entered from templates

Post by tatewise »

I have performed some experiments involving Date metafields.

My findings for displayed Dates are the opposite of yours.
The Access Date: field in the Citation Window is always displayed in Compact format using the Tools > Preferences > General tab setting for Preferred Standard Date Format which is usually 'dd mmm yyyy'
i.e. 11 Feb 2024
In the Footnote where {Access_Date} displays the date, it uses the Long format, i.e. 11 February 2024.

To change that is a little technical because the :COMPACT date formatting qualifier cannot be applied to the {Access_Date} date code and the metafield shortcut data reference must be used instead.
i.e. {%SOUR.~DT-ACCESS_DATE:COMPACT%}
So with that change, the Footnote will display the date in Compact format as 11 Feb 2024.

So in theory the Footnote code with today's date default alternative would be:
<{%SOUR.~DT-DATE:COMPACT%}|{=Today()}>
However, that won't achieve what you expect because =Today() is dynamic and always returns today's date.
So when the Access Date field is empty the Footnote date would be always changing day by day.

In other words, it is actually the Access Date field you need to default to today's date and save it permanently.
Unfortunately, I don't believe this is possible unless you use a DEA.

It is probably the dynamic nature of =Today() that causes FH to crash if the code above is used.
I think you should report that FH crash scenario to CP as it should not happen but either ignore the =Today() function or report its misuse.

I hope that all makes sense.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
avatar
Gary_G
Megastar
Posts: 756
Joined: 24 Mar 2023 19:05
Family Historian: V7

Re: Question about formatting dates entered from templates

Post by Gary_G »

Thank you, Mike.

Yes. Your explanation makes perfect sense. I see your point about =Today() being dynamic and the possible reason for the crashes. [I likely did get the results backwards. It's difficult to document things when FH keeps crashing :D ] Wrt. reporting the crash issue to CP... I'm not sure how one does that, since I've not had to do that before. Will have a look-see and do what I can.

Ancestral Sources is a potential candidate for the DEA solution to which you referred. If I leave just the {Access_Date} in my template and map the A.S. {SYSTEM.DATE} to it, things should work. I must check what format A.S. puts out, though, and whether the access date needs to be formatted by my template. If I need to force a specific date, I should be able to do so prior to saving the record.
Last edited by tatewise on 11 Feb 2024 22:45, edited 1 time in total.
Reason: Corected =Date() to =Today()
Gary Gauthier
Hunting History in the Wild!
User avatar
tatewise
Megastar
Posts: 28488
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: Question about formatting dates entered from templates

Post by tatewise »

Sorry, I assumed you would have needed to contact CP before now.
Use their https://support.calico-pie.com/open.php Support Centre Ticket System.

Yes, your proposed AS solution should work.
No need to worry about AS date format as it is sure to be FH compatible.
Inside FH all dates are stored in the same, probably GEDCOM, format.
Everything else will work as I described earier.
The Access Date field will always display in Compact dd mmm yyyy format like any other Date field.
The Footnote will display in Compact format if you use the {%SOUR.~DT-ACCESS_DATE:COMPACT%} code.

BTW: I've moved this to the Sources, Citations & Repositories forum.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
avatar
Gary_G
Megastar
Posts: 756
Joined: 24 Mar 2023 19:05
Family Historian: V7

Re: Question about formatting dates entered from templates

Post by Gary_G »

Thanks, Mike.

No. I've not had a reason to contact them directly before now.
Usually; I would only consider doing that for a clear issue with the code.
To date, the crashing was the first time I've had something that didn't have a "soft" solution.
Gary Gauthier
Hunting History in the Wild!
Post Reply