Received: from gyw.com (gyw.com [209.55.67.177]) by postgresql.org (8.11.3/8.11.1) with ESMTP id f4IH1GA78760 for ; Fri, 18 May 2001 13:01:16 -0400 (EDT) (envelope-from tjk@tksoft.com) Received: from smtp3.tksoft.com (smtp3.tksoft.com [192.168.50.56] (may be forged)) by gyw.com (8.8.8/8.8.8) with ESMTP id KAA15403; Fri, 18 May 2001 10:33:12 -0700 Received: (from tjk@tksoft.com) by smtp3.tksoft.com (8.8.8/8.8.8) id IAA13471; Fri, 18 May 2001 08:53:31 -0700 From: "tjk@tksoft.com" Message-Id: <200105181553.IAA13471@smtp3.tksoft.com> Subject: Re: Calculating the age of a person To: hs@cybertec.at (=?iso-8859-1?Q?Hans=2DJ=FCrgen=20Sch=F6nig?=) Date: Fri, 18 May 2001 08:53:29 -0700 (PDT) Cc: pgsql-sql@postgresql.org In-Reply-To: from "=?iso-8859-1?Q?Hans=2DJ=FCrgen=20Sch=F6nig?=" at May 18, 2001 03:39:15 PM X-Info: None MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Archive-Number: 200105/202 X-Sequence-Number: 3019 You are probably looking for date_part(). E.g. SELECT date_part('year',age(birth)),* FROM persons LIMIT 1; Troy > > 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 >