Received: from lin.local.lan ([216.221.221.2]) by postgresql.org (8.11.3/8.11.1) with ESMTP id f4MELaA80155 for ; Tue, 22 May 2001 10:21:36 -0400 (EDT) (envelope-from najm@mondo-live.com) Received: from mondo-live.com (IDENT:najm@najm.local2.lan [192.168.2.20]) by lin.local.lan (8.9.3/8.8.7) with ESMTP id OAA11587; Tue, 22 May 2001 14:55:05 GMT Message-ID: <3B0A75C8.2020906@mondo-live.com> Date: Tue, 22 May 2001 10:20:56 -0400 From: Najm Hashmi User-Agent: Mozilla/5.0 (X11; U; Linux 2.2.14-5.0 i686; en-US; m18) Gecko/20001018 X-Accept-Language: en MIME-Version: 1.0 To: =?ISO-8859-1?Q?Hans=2DJ=FCrgen=20Sch=F6nig?= CC: pgsql-sql@postgresql.org Subject: Re: Calculating the age of a person References: <3B052603.ADBEB496@cybertec.at> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Archive-Number: 200105/242 X-Sequence-Number: 3067 Hans-Jürgen Schönig wrote: > I have a table containing the birthdays of various persons. The target > is to compute the age of a persons. > > persons=# SELECT age(birth), * FROM persons LIMIT 1; > age | id | name | birth | gender | > income > -------------------------------+----+--------+------------+--------+-------- > > 31 years 4 mons 16 days 23:00 | 1 | Albert | 1970-01-01 | m | > 35000 > (1 row) > > When I use age() I don't get full years. Is there an easy way to round > ::reltime off or up without writing a function. Is there any possibility > to use plain SQL only? > > Hans > > > ---------------------------(end of broadcast)--------------------------- > TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org Hey Hans try usting date_part function.... select date_part('year',birth).... Regards -- Najm Hashmi Tel:514-271-9791 www.mondo-live.com www.flipr.com