Calculate the length of a marriage (How To)

Introduction

The function below will calculate in years the length of a marriage. To compute the end of the marriage is uses the follow dates in order

  1. Divorce Date if it exists
  2. Husband's Death Date, if it exists and is earlier than the Wife's Death
  3. Wife's Death Date

If there is no marriage date or none of the above exists the function will return a Null (the value of the Wife's death date)

Details

Join back into one line to use.

=Timespan(%FAM.MARR.DATE%,Dateif(exists(%FAM.DIV.DATE%),%FAM.DIV.DATE%,
Dateif((exists(%FAM.HUSB>DEAT.DATE%) 
and (%FAM.HUSB>DEAT.DATE% <= %FAM.WIFE>DEAT.DATE%)) 
or not(exists(%FAM.WIFE>DEAT.DATE%)),
%FAM.HUSB>DEAT.DATE%,%FAM.WIFE>DEAT.DATE%)),YEARS)

Returns the type of Date eg Before After from the second date used. The XDATETYPE will return the type of the date. If you wanted to you could combine the two into a single column on your Query or you might want to show the XDATETYPE for the marriage date as well.

=TextIf(Exists(%FAM.DIV.DATE%),%FAM.DIV.DATE:XDATETYPE%,
TextIf((Exists(%FAM.HUSB>DEAT.DATE%) 
and (%FAM.HUSB>DEAT.DATE% <= %FAM.WIFE>DEAT.DATE%)) 
or Not(Exists(%FAM.WIFE>DEAT.DATE%)),
%FAM.HUSB>DEAT.DATE:XDATETYPE%,%FAM.WIFE>DEAT.DATE:XDATETYPE%))

Section how_to