Received: from postgresql.org.org (webmail.postgresql.org [216.126.85.28]) by postgresql.org (8.11.3/8.11.1) with SMTP id f4IEbBA98413 for ; Fri, 18 May 2001 10:37:11 -0400 (EDT) (envelope-from pgsql-sql-owner@postgresql.org) Received: from news.tht.net (news.hub.org [216.126.91.242]) by postgresql.org (8.11.3/8.11.1) with ESMTP id f4IDvTA78241 for ; Fri, 18 May 2001 09:57:29 -0400 (EDT) (envelope-from news@news.tht.net) Received: (from news@localhost) by news.tht.net (8.11.1/8.11.1) id f4IDa7q13266 for pgsql-sql@postgresql.org; Fri, 18 May 2001 09:36:07 -0400 (EDT) (envelope-from news) From: =?iso-8859-1?Q?Hans=2DJ=FCrgen=20Sch=F6nig?= X-Newsgroups: comp.databases.postgresql.sql Subject: Calculating the age of a person Date: Fri, 18 May 2001 15:39:15 +0200 Organization: Hub.Org Networking Services (http://www.hub.org) Lines: 18 Message-ID: <3B052603.ADBEB496@cybertec.at> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Complaints-To: scrappy@hub.org X-Mailer: Mozilla 4.77 [de] (X11; U; Linux 2.4.2-2 i686) X-Accept-Language: en To: pgsql-sql@postgresql.org X-Archive-Number: 200105/198 X-Sequence-Number: 3015 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