Page 1 of 1

AGE AT formatting in Queries

Posted: 22 Apr 2022 10:38
by Little.auk
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?

Re: AGE AT formatting in Queries

Posted: 22 Apr 2022 11:05
by Jane
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.

Re: AGE AT formatting in Queries

Posted: 22 Apr 2022 12:48
by Little.auk
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).