* AGE AT formatting in Queries

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
Little.auk
Famous
Posts: 224
Joined: 23 Jul 2021 08:51
Family Historian: V7
Location: Tamworth, Staffordshire, UK

AGE AT formatting in Queries

Post by Little.auk » 22 Apr 2022 10:38

I have a query, one of the uses of which is checking for missing census records for individuals. It uses the expression %INDI.CENS[year=1841].AGE% to return the individuals age at the census.

I want to export this query as a csv file to use in an Excel spreadsheet and want the age as a simple numeric value, however, when I enter the age in the Fact "Age" field in the Property Box it displays in the format "51 yrs" ( I am only entering age in years ). This format is also applied in the query.

I have tested using the "=LeftText" function, which works, but needs to be combined with "=TextLen" to deal with single digit ages below 10 and three digit ages above 99.

Is there a simpler way of formatting this to just show the numeric age without the " yrs" suffix?
Peter Rollin
Running FH 7.0.20 and AS 7.7.7 64 bit in Windows 11

User avatar
Jane
Site Admin
Posts: 8441
Joined: 01 Nov 2002 15:00
Family Historian: V7
Location: Somerset, England
Contact:

Re: AGE AT formatting in Queries

Post by Jane » 22 Apr 2022 11:05

You can use

Code: Select all

=TextToNumber(%INDI.CENS[year=1841].AGE%)
but remember someone recorded as 18mths or 4 weeks will show as 18 and 4 respectfully.
Jane
My Family History : My Photography "Knowledge is knowing that a tomato is a fruit. Wisdom is not putting it in a fruit salad."

avatar
Little.auk
Famous
Posts: 224
Joined: 23 Jul 2021 08:51
Family Historian: V7
Location: Tamworth, Staffordshire, UK

Re: AGE AT formatting in Queries

Post by Little.auk » 22 Apr 2022 12:48

Thanks Jane,

I never thought of using TextToNumber, it does exactly what I want.

I have one or two 1921 census ages that are less that a year old, so I ran a test by entering zero in the years box for one child who was 9 months old. This displays as 0 yrs 9 mns in the Property Box.

The FH Census Fact sentence strips the "0 yrs" and returns "aged 9 months" -- as it did with the year left blank. My query returns 0. So, a win all round ---- (as long as I remember to put zero in the years box).
Peter Rollin
Running FH 7.0.20 and AS 7.7.7 64 bit in Windows 11

Post Reply