Re: birthday calculation

From: Network Administrator <netadmin(at)vcsn(dot)com>
To: Ben <bench(at)silentmedia(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: birthday calculation
Date: 2003-07-23 20:47:21
Message-ID: 1058993241.3f1ef45926bff@webmail.vcsn.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

hmmmm, I use this on an ecommunities type site- I haven't seen any errors. This
is also a pg 7.1.3

As an example, something like this might be executed:

select date_trunc('year',age(to_date(dob,'MM/DD/YYYY'))) as age from members
where memid=101;

Quoting Ben <bench(at)silentmedia(dot)com>:

> It must be late, because I cannot seem to figure this out. I've got a
> field which has a user's birthday - I want to figure out how old they
> are in terms of years.
>
> If I just do something like:
>
> select current_date - user.bday;
>
> I get their age in days, which doesn't let me take leap years into
> account. Is there a simple magic date_diff function that I'm missing? Or
> lacking that some other way to get postgres to do the date calculations?
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 9: the planner will ignore your desire to choose an index scan if your
> joining column's datatypes do not match
>

--
Keith C. Perry
Director of Networks & Applications
VCSN, Inc.
http://vcsn.com

____________________________________
This email account is being host by:
VCSN, Inc : http://vcsn.com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Dmitry Tkach 2003-07-23 20:52:54 Re: [GENERAL] Convert TimeStamp to Date
Previous Message scott.marlowe 2003-07-23 20:32:06 Re: Join Problem