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?
* AGE AT formatting in Queries
-
Little.auk
- Famous
- Posts: 224
- Joined: 23 Jul 2021 08:51
- Family Historian: V7
- Location: Tamworth, Staffordshire, UK
AGE AT formatting in Queries
Peter Rollin
Running FH 7.0.20 and AS 7.7.7 64 bit in Windows 11
Running FH 7.0.20 and AS 7.7.7 64 bit in Windows 11
- Jane
- Site Admin
- Posts: 8441
- Joined: 01 Nov 2002 15:00
- Family Historian: V7
- Location: Somerset, England
- Contact:
Re: AGE AT formatting in Queries
You can use
but remember someone recorded as 18mths or 4 weeks will show as 18 and 4 respectfully.
Code: Select all
=TextToNumber(%INDI.CENS[year=1841].AGE%)Jane
My Family History : My Photography "Knowledge is knowing that a tomato is a fruit. Wisdom is not putting it in a fruit salad."
My Family History : My Photography "Knowledge is knowing that a tomato is a fruit. Wisdom is not putting it in a fruit salad."
-
Little.auk
- Famous
- Posts: 224
- Joined: 23 Jul 2021 08:51
- Family Historian: V7
- Location: Tamworth, Staffordshire, UK
Re: AGE AT formatting in Queries
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).
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
Running FH 7.0.20 and AS 7.7.7 64 bit in Windows 11