Re: birthday calculation

From: Dennis Gearon <gearond(at)cvc(dot)net>
To: Pavel Stehule <stehule(at)kix(dot)fsv(dot)cvut(dot)cz>
Cc: Ben <bench(at)silentmedia(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: birthday calculation
Date: 2003-07-23 07:43:08
Message-ID: 3F1E3C8C.7040707@cvc.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1">
<title></title>
</head>
<body text="#000000" bgcolor="#ffffff">
How come it gives 23 hours, is that correct?Pavel Stehule wrote:
<blockquote type="cite">
<pre wrap="">Hello

SELECT age(CURRENT_DATE, date '730715');
age
--------------------------
30 years 7 days 23:00:00
(1 row)

bye
ps

On 22 Jul 2003, Ben wrote:

</pre>
<blockquote type="cite">
<pre wrap="">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

</pre>
</blockquote>
<pre wrap=""><!---->

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to <a class="moz-txt-link-abbreviated" href="mailto:majordomo(at)postgresql(dot)org">majordomo(at)postgresql(dot)org</a>

</pre>
</blockquote>
<br>
<br>
</body>
</html>

Attachment Content-Type Size
unknown_filename text/html 1.5 KB

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Kaarel 2003-07-23 07:44:35 Re: dump_all/restore times?
Previous Message Peter Eisentraut 2003-07-23 07:32:43 Re: 0/1 vs true/false