You can calculate age using the following script:-
start = datetime.strptime(object.birthdate, DEFAULT_SERVER_DATE_FORMAT)
end = datetime.strptime(time.strftime(DEFAULT_SERVER_DATE_FORMAT), DEFAULT_SERVER_DATE_FORMAT)
delta = end - start
age = (delta.days / 365)
Please don't forget to import following:-
from dateutil.relativedelta import relativedelta
from datetime import datetime
from openerp.tools import DEFAULT_SERVER_DATE_FORMAT, DEFAULT_SERVER_DATETIME_FORMAT
Hope this helps,, please let me know if it does.
Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!
About This Community
|Asked: 1/29/15, 11:12 AM|
|Seen: 732 times|
|Last updated: 3/16/15, 8:10 AM|