View Single Post
 
Old 09-12-2023, 10:54 AM
Charles Kenyon Charles Kenyon is offline Windows 11 Office 2021
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,536
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

Here is a screenshot comparing your field, as repaired by Jay Freedman, and one from the tutorial.

The date picker has a bookmark set of "Birthdate."
When a date is entered and then the fields are selected and updated (F9), the result is:


What is the birthdate? 6/20/1966

Your field
Age:

Field from tutorial with BirthDate substituted for StartDate and Date substituted for EndDate.
57 Years, 2 Months, 22 Days.

================================
Note, your field produced no result. I have no interest in trying to fix it. Jay Freedman, in your other post already corrected the matching of braces.



Here is the second field in text, which could be converted to a real field using Graham Mayor's utility. (Do not try typing it yourself unless you really like pain.)

{QUOTE{SET sy{BirthDate \@ yyyy}}{SET sm{BirthDate \@ M}}{SET sd{BirthDate \@ d}}{SET ey{Date \@ yyyy}}{SET em{Date \@ M}}{SET ed{Date \@ d}}{SET md{=IF((em=2),28+(em=2)*((MOD(ey,4)=0)+(MOD(ey,400 )=0)-(MOD(ey,100)=0)),31-((em=4)+(em=6)+(em=9)+(em=11)))}}{Set Years{=ey-sy-(em<sm)-(em=sm)*(ed<sd)}}{Set Months{=MOD(12+em-sm-(ed<sd),12) \# 0}}{Set Days{=MOD(md+ed-sd,md) \# 0}}"{Years} Year{IF{Years}= 1 "" s}, {Months} Month{IF{Months}= 1 "" s}, {Days} Day{IF{Days}= 1 "" s}."}


Here it is in text trimmed to simply produce the number of years.


{QUOTE
{SET sy{BirthDate \@ yyyy}}
{SET sm{BirthDate \@ M}}
{SET sd{BirthDate \@ d}}
{SET ey{Date \@ yyyy}}
{SET em{Date \@ M}}
{SET ed{Date \@ d}}
{SET md{=IF((em=2),28+(em=2)*((MOD(ey,4)=0)+(MOD(ey,400 )=0)-(MOD(ey,100)=0)),31-((em=4)+(em=6)+(em=9)+(em=11)))}}
{Set Years{=ey-sy-(em<sm)-(em=sm)*(ed<sd)}}
"{Years}"}

Last edited by Charles Kenyon; 09-16-2023 at 10:17 AM.
Reply With Quote