Doing age formula

I am trying to have Panorama figure out an age for me.
In Pan 6 I would have the player birthdate field, Date field and age field.

In Pan 6 I used the procedure:

Field “Age”
FormulaFill (Date-Player birthdate)/365.25

In Pan X I get a warning that says Missing Right Parenthesis.

So what do I put in the formula to make it work???
Thanks

I doubt that it worked in Pan 6, as chevrons («») are required for field names that consist of multiple words.

FormulaFill (Date-«Player birthdate»)/365.25 will work.

Thanks,
Have one more question, if I wanted to go a step further and have it figure out age, months and days what do I need to do???

Have a look in the documentation:

Ok, saw that in the documentation.
I still can’t find out how to do this:
If a persons birthdate is March 1, 1940, he was 28 years, 9 months, 7 days old on December 8, 1968.

Can I figure this out in Pan X???

Quite long but this will work:

formulafill ?(Birthday=0,“”,pattern(yearsbetween(Birthday,Date),“# Year~ “)+pattern(((12+(val(datepattern(Date,“MM”))-val(datepattern(Birthday,“MM”)))-?(val(datepattern(Date,“DD”))-val(datepattern(Birthday,“DD”))<0,1,0)) mod 12),”# Month~ “)+pattern((31+val(datepattern(Date,“DD”))-val(datepattern(Birthday,“DD”))) mod 31,”# Day~”))

Not quite there yet but do take a look at MonthValue( to make it a bit simpler.

Not only is this simpler, but this will also be applicable for future dates:

Date Difference:
formulafill ?(Birthday=0,“”,pattern(yearsbetween(min(Date,Birthday),max(Date,Birthday)),“# Year~ “)+pattern(((12+(monthvalue(max(Date,Birthday))-monthvalue(min(Date,Birthday)))-?(dayvalue(max(Date,Birthday))-dayvalue(min(Date,Birthday))<0,1,0)) mod 12),”# Month~ “)+pattern((31+dayvalue(max(Date,Birthday))-dayvalue(min(Date,Birthday))) mod 31,”# Day~”))

Age:
formulafill ?(Birthday=0,“”,?(Date<Birthday,“-”,“”)+pattern(yearsbetween(min(Date,Birthday),max(Date,Birthday)),“# Year~ “)+pattern(((12+(monthvalue(max(Date,Birthday))-monthvalue(min(Date,Birthday)))-?(dayvalue(max(Date,Birthday))-dayvalue(min(Date,Birthday))<0,1,0)) mod 12),”# Month~ “)+pattern((31+dayvalue(max(Date,Birthday))-dayvalue(min(Date,Birthday))) mod 31,”# Day~”))

I tried both Date Difference and Age, and both times I got an error
Missing Right Parenthesis. So were am I suppose to put that???

It appears that all quotation marks have been converted to curly ones. Changing them will work fine.

So how would the code then look, have noideaon converting curly ones???
Sorry

No curly quotes:

//Date Difference:

formulafill ?(Birthday=0,"",pattern(yearsbetween(min(Date,Birthday),max(Date,Birthday)),"# Year~ ")+pattern(((12+(monthvalue(max(Date,Birthday))-monthvalue(min(Date,Birthday)))-?(dayvalue(max(Date,Birthday))-dayvalue(min(Date,Birthday))<0,1,0)) mod 12),"# Month~ ")+pattern((31+dayvalue(max(Date,Birthday))-dayvalue(min(Date,Birthday))) mod 31,"# Day~"))

//Age:

formulafill ?(Birthday=0,"",?(Date<Birthday,"-","")+pattern(yearsbetween(min(Date,Birthday),max(Date,Birthday)),"# Year~ ")+pattern(((12+(monthvalue(max(Date,Birthday))-monthvalue(min(Date,Birthday)))-?(dayvalue(max(Date,Birthday))-dayvalue(min(Date,Birthday))<0,1,0)) mod 12),"# Month~ ")+pattern((31+dayvalue(max(Date,Birthday))-dayvalue(min(Date,Birthday))) mod 31,"# Day~"))

Still getting error

Yes the field is Player birthday, not Birthdate

//Date Difference:
formulafill ?(«Player birthday»=0,"",pattern(yearsbetween(min(Date,«Player birthday»),max(Date,«Player birthday»)),"# Year~ ")+pattern(((12+(monthvalue(max(Date,«Player birthday»))-monthvalue(min(Date,«Player birthday»)))-?(dayvalue(max(Date,«Player birthday»))-dayvalue(min(Date,«Player birthday»))<0,1,0)) mod 12),"# Month~ ")+pattern((31+dayvalue(max(Date,«Player birthday»))-dayvalue(min(Date,«Player birthday»))) mod 31,"# Day~"))

//Age:
formulafill ?(«Player birthday»=0,"",?(Date<«Player birthday»,"-","")+pattern(yearsbetween(min(Date,«Player birthday»),max(Date,«Player birthday»)),"# Year~ ")+pattern(((12+(monthvalue(max(Date,«Player birthday»))-monthvalue(min(Date,«Player birthday»)))-?(dayvalue(max(Date,«Player birthday»))-dayvalue(min(Date,«Player birthday»))<0,1,0)) mod 12),"# Month~ ")+pattern((31+dayvalue(max(Date,«Player birthday»))-dayvalue(min(Date,«Player birthday»))) mod 31,"# Day~"))

Ok, got it to work, thanks

Once upon a time, in high school, a teacher had me and another classmate run a lap around the track and return to the classroom. The details of “why” are not important but we weren’t in trouble. Though I knew I could beat him in a sprint at the end, we never established “the end” point. Was it at the end of the track loop? Was it when we reached the classroom building (We weren’t supposed to run in the halls)? Was it at the classroom door?

Because I didn’t know were the finish line was, I didn’t know when to start my sprint. That gave me a lifelong lesson - not to start a task until I have some idea of that “finish” looks like.

So a simple question like - How do I calculate someone’s age can be far more complicated than you’d image. Because, technically, each year, each month, each week, each day, each hour, each minute, each second, that age changes.

Also, do you want it displayed as just a year, or a year with a decimal point indicating the fractional part of months? Do you round it to the year/month or not increment the age in the “birth” month until the birth-day has passed?

And note my comment about the age changing by the second. I’m guessing you might want the routine to run every time you open the database - unless you create a flag that tells you you’ve already run it once for the day so don’t need to run it again.

I do see you gave an example for March 1, 1940. You wanted the year, month, and days old on another year/month/day. Is that what you want returned - a sentence that says, “yy years, mm months, dd days”?

What triggers that calculation?

See, the actual calculation is pretty trivial - it’s the “finish line” that has so much variability.

Back in the day, we try to accommodate things like the fraction of a year (365.25). But it’s much simpler than that. When someone asks you how old you or something is, you usually don’t divide by some fractional number.

Usually, by knowning if the birthday has already occured in the year in question (because you know the month/day), You know the years are the “ask” year minus the birthdate year or the ask year minus the birthdate year minus 1 if the birthday hasn’t occured yet in the ask year. Either way, it’s simple arithmetic with an 'IF" adjustment depending upon the birthday having already occured or not in the ask year.

This same idea continues if you want the month - one of two calculations depending upon if the birth month has passed or not. And so on for the day.

The problem with your 365.25 is not only do you have leap year (which your .25 is supposed to accommodate with integer arithmetic), but if the year lands on a 100 year boundary the leap year is not added. UNLESS, that 100 year boundary is also divisible by 400 (like the year 2000).

You can accommodate all that in a formula (I used to have one memorized that would take that all into account and tell me what day any date fell on). But so much easier - and clearer when you visit the issue six months later - if you look at the year difference, then the month difference, then the day difference and put them together.

I guess you’d need to also check on the 100 year and 400 year situation to calculate the days too.

But your choice - no right way; just different ways. :slightly_smiling_face:

It would return the correct year and month, but day is not quite right, so here is the correct version:

//Date Difference:
formulafill ?(«Player birthday»=0,"",pattern(yearsbetween(min(Date,«Player birthday»),max(Date,«Player birthday»)),"# Year~ ")+pattern(((12+(monthvalue(max(Date,«Player birthday»))-monthvalue(min(Date,«Player birthday»)))-?(dayvalue(max(Date,«Player birthday»))-dayvalue(min(Date,«Player birthday»))<0,1,0)) mod 12),"# Month~ ")+pattern((monthlength(min(Date,«Player birthday»))+dayvalue(max(Date,«Player birthday»))-dayvalue(min(Date,«Player birthday»))) mod monthlength(min(Date,«Player birthday»)),"# Day~"))

//Age:
formulafill ?(«Player birthday»=0,"",?(Date<«Player birthday»,"-","")+pattern(yearsbetween(min(Date,«Player birthday»),max(Date,«Player birthday»)),"# Year~ ")+pattern(((12+(monthvalue(max(Date,«Player birthday»))-monthvalue(min(Date,«Player birthday»)))-?(dayvalue(max(Date,«Player birthday»))-dayvalue(min(Date,«Player birthday»))<0,1,0)) mod 12),"# Month~ ")+pattern((monthlength(min(Date,«Player birthday»))+dayvalue(max(Date,«Player birthday»))-dayvalue(min(Date,«Player birthday»))) mod monthlength(min(Date,«Player birthday»)),"# Day~"))

This is trickier than I thought. The formula has been fixed as it returned wrong ‘Days’ info, particularly for February birthdays.
While the age formula has been simplified, it is only applicable to dates prior to the ‘Date’.
Additionally, both formulas return the total number of weeks and days.

//Age:
formulafill ?(«Player birthday»=0 or Date<«Player birthday»,"",pattern(yearsbetween(«Player birthday»,Date),"# Year~ ")+pattern((12+(monthvalue(Date)-monthvalue(«Player birthday»))-?(dayvalue(Date)-dayvalue(«Player birthday»)<0,1,0)) mod 12,"# Month~ ")+pattern((monthlength(«Player birthday»)+dayvalue(Date)-dayvalue(«Player birthday»)) mod monthlength(«Player birthday»)+?(monthlength(«Player birthday»)≤dayvalue(Date)-dayvalue(«Player birthday»),monthlength(«Player birthday»),0),"# Day~")+pattern(abs(Date-«Player birthday»)," [#, Day~ | ")+pattern(abs(Date-«Player birthday»)\7,"#, Week~")+pattern(abs(Date-«Player birthday») mod 7," # Day~]"))

//Date Difference:
formulafill ?(«Player birthday»=0,"",pattern(yearsbetween(min(Date,«Player birthday»),max(Date,«Player birthday»)),"# Year~ ")+pattern((12+(monthvalue(max(Date,«Player birthday»))-monthvalue(min(Date,«Player birthday»)))-?(dayvalue(max(Date,«Player birthday»))-dayvalue(min(Date,«Player birthday»))<0,1,0)) mod 12,"# Month~ ")+pattern((monthlength(min(Date,«Player birthday»))+dayvalue(max(Date,«Player birthday»))-dayvalue(min(Date,«Player birthday»))) mod monthlength(min(Date,«Player birthday»))+?(monthlength(min(Date,«Player birthday»))≤dayvalue(max(Date,«Player birthday»))-dayvalue(min(Date,«Player birthday»)),monthlength(min(Date,«Player birthday»)),0),"# Day~")+pattern(abs(Date-«Player birthday»)," [#, Day~ | ")+pattern(abs(Date-«Player birthday»)\7,"#, Week~")+pattern(abs(Date-«Player birthday») mod 7," # Day~]"))