extract day from interval

From: Seb <spluque(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: extract day from interval
Date: 2008-03-28 03:32:05
Message-ID: 87bq4zplqi.fsf@patagonia.sebmags.homelinux.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

I'm not very savvy with interval manipulations, but I have a query like
this:

---<---------------cut here---------------start-------------->---
SELECT DISTINCT ON (table_a.id) table_a.id, table_a.var2,
EXTRACT(DAY FROM (table_b.date - table_a.date)) AS age,
FROM table_a INNER JOIN table_b
ON (table_a.id = table_b.id)
WHERE table_a.date IS NOT NULL
ORDER BY table_a.pupid, age;
---<---------------cut here---------------end---------------->---

Is this an efficient way to get the days from the time interval? Both
'date' columns are of type "Date". Thanks.

Cheers,

--
Seb

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2008-03-28 04:06:59 Re: extract day from interval
Previous Message Robert Treat 2008-03-28 03:30:57 Re: Re: Survey: renaming/removing script binaries (createdb, createuser...)