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

Re: Regarding interval conversion functions and a seeming lack of usefulness

From: Alban Hertroys <dalroi(at)solfertje(dot)student(dot)utwente(dot)nl>
To: Bill Moran <wmoran(at)collaborativefusion(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Regarding interval conversion functions and a seeming lack of usefulness
Date: 2008-02-28 12:04:44
Message-ID: E46962A9-3ABD-49CE-B512-111170CAAB9D@solfertje.student.utwente.nl (view raw or flat)
Thread:
Lists: pgsql-general
On Feb 27, 2008, at 3:47 PM, Bill Moran wrote:
> Something like:
> $ SELECT CONVERT('12 days 13 hours'::INTERVAL AS hour);
>  hour
> ------
>    301
> $ SELECT CONVERT('6 hours 17 minutes'::INTERVAL AS hour);
>  hour
> ------
> 6.2833
>
> Am I approaching this problem wrong? or is there something out there
> and my Google skills are lacking?

One of the obvious problems with this is that you cannot convert  
months to something more fine-grained without knowing the date the  
interval is relative to. I mean, what would be the answer of:

$ SELECT CONVERT('2 months'::INTERVAL AS days);

This month that would be 60 days, next month 61, this month next year  
59, etc.
And I haven't even started on leap seconds and daylight saving time  
yet...

Alban Hertroys

--
If you can't see the forest for the trees,
cut the trees and you'll see there is no forest.


!DSPAM:737,47c69dd2233091191611641!



In response to

Responses

pgsql-general by date

Next:From: Michael GlaesemannDate: 2008-02-28 13:05:57
Subject: Re: UUID-OSSP for windows.
Previous:From: Sam MasonDate: 2008-02-28 11:35:59
Subject: Re: How to "paste two tables side-by-side"?

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