Re: [SQL] this one's simpler - Mailing list pgsql-sql

From Maarten Boekhold
Subject Re: [SQL] this one's simpler
Date
Msg-id Pine.SUN.3.91.980825093939.865A-100000@dutepp2.et.tudelft.nl
Whole thread Raw
In response to this one's simpler  (Eric McKeown <ericm@palaver.net>)
Responses Having problems to compile SPI
List pgsql-sql
On Mon, 24 Aug 1998, Eric McKeown wrote:

> Ok, I think this questions is a little bit easier.  I have this piece of
> code:
>
> select (max(date_asked) - min(date_asked))::timespan from questions ;
>
> And it produces this output:
>
> timespan
> ------------------------------------
> @ 2334 days 13 hours 21 mins 45 secs
> (1 row)
>
> Now, what I'd really like is a way to format that output into months so
> that I could see the difference between the two dates in terms of months.
> Pointers??

Well, since not every month has the same number of days, and not every
*year* has the same number of days, I think this would only be possible
if you also give same starting date (ie min(date_asked)). I'd try to
write a C-function for this I guess.

Maarten

_____________________________________________________________________________
| TU Delft, The Netherlands, Faculty of Information Technology and Systems  |
|                   Department of Electrical Engineering                    |
|           Computer Architecture and Digital Technique section             |
|                          M.Boekhold@et.tudelft.nl                         |
-----------------------------------------------------------------------------


pgsql-sql by date:

Previous
From: Cho Yan Wong
Date:
Subject: copy probs
Next
From: Andreas Schmidt
Date:
Subject: Query otimizing possible?