Re: Calculate age
- From: Murray Cumming <murrayc murrayc com>
- To: Manuel Rodríguez Núñez <mrnunez cruceirobaleares es>
- Cc: glom-devel-list <glom-devel-list gnome org>
- Subject: Re: Calculate age
- Date: Thu, 15 Apr 2010 09:49:15 +0200
(You sent this to the mailing list admin address, not the mailing list itself.
I'm replying to the mailing list.)
On Sun, 2010-04-11 at 20:16 +0200, Manuel Rodríguez Núñez wrote:
First, sorry for my English.
I'm trying glom and I not know the python language, I have a calculated
field for age.
How I can calculate the age based on a field with the date of birth?
In Filemaker simply subtract the birth date to the current date.
Thanks
I assume that you want the age in years. I don't actually think it's as
simple as you say in FileMaker, but I'd like to see an example, please.
It doesn't seem easy in Python either. This should work, but probably
doesn't in your current Glom version. I'm currently checking that this
works in Glom 1.14:
from dateutil.relativedelta import relativedelta
import datetime
rd = relativedelta(datetime.date.today(), record["date_of_birth"])
return rd.year;
I am tempted to provide an easier way to do this, such as
return glom_utils.calculate_age(record["date_of_birth"]);
--
murrayc murrayc com
www.murrayc.com
www.openismus.com
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]