2007/3/5, Joe Smith <[EMAIL PROTECTED]>:
Eugénio Varejão wrote: > I'm using OO Writer to write a contract between a person and an > institution. I want calculate in text the age of the individual: I have > a the born date and the present day. How can do this? Insert > Fields > Other > Variables > Set variable Name: Birth_date Value: 1/1/1950 Format: (Additional formats > Date > [pick one]) Insert > Fields > Other > Variables > Set variable Name: Document_date Value: 3/5/2007 Format: (Additional formats > Date > [pick one]) Insert > Fields > Other > Variables > Formula Value: Document_date - Birth_date Format: General (default) This will show the person's age in days. This is because the date variables store the date as an integer number of days since December 30, 1899.
Yes, but isn't that somewhat strange? Shouldn't it be 1899-12-31 rather than 1899-12-30? Why is 0 days = 1899-12-30? If I do something like 2007-03-05 - 2007-03-03 the answer should be 2 (days), right? But if I enter 2007-03-05 in A1, 2007-03-03 in B1and =A1-B1 in C1, and then format C1 as DD, C1 shows 01, not 02 which I think would be more appropriate. So why is 0 days = 1899-12-30? *All dates above are in the ISO 8601<http://freedos-32.sourceforge.net/showdoc.php?page=standards#iso8601>date format, which also is Swedish standard and the only format I'm used to. * So, to see the age in years, change the formula field to
(Document_date - Birth_date)/365.25
Or just Document_date - Birth_date + 1, formatted as YY. If you want to show an integer number of years, choose a number format
like "1234" (no decimal part), but be aware that this _rounds_ to the nearest year, which may not be acceptable. We normally don't count a person as one year older until their birthday is past.
I do, but it depends on the situation, but maybe that's my problem only. <Joe
