Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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

pgsql-general by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group