Re: question about postgresql time intervals - Mailing list pgsql-general

From Linda
Subject Re: question about postgresql time intervals
Date
Msg-id 200603160849.10840.lgray@unitrends.com
Whole thread Raw
In response to Re: question about postgresql time intervals  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: question about postgresql time intervals  (Michael Glaesemann <grzm@myrealbox.com>)
List pgsql-general
On Wednesday 15 March 2006 8:13 pm, Tom Lane wrote:
> Michael Glaesemann <grzm@myrealbox.com> writes:
> > On Mar 15, 2006, at 23:39 , Linda wrote:
> >> According to the SQL standard, shouldn't this work?
> >>
> >> select '506:47:04'::interval day to second ;
>
> > No one has implemented this in PostgreSQL yet.
>
> It depends on what you define as "work".  8.1 says
>
> regression=# select '506:47:04'::interval day to second ;
>  interval
> -----------
>  506:47:04
> (1 row)
>
> 8.0 and before say
>
> regression=# select '506:47:04'::interval day to second ;
>      interval
> ------------------
>  21 days 02:47:04
> (1 row)
>
> because before 8.1 we didn't distinguish intervals of "1 day" and "24
hours"
> as being different.  But the syntax has been accepted for a long time,
> at least back to 7.0.
>
> If there's some specific functionality you're after, you should say what
> it is rather than expecting us to guess what you mean.
>

Hi, Tom

Thanks for your reply.  I guess you missed the original email.  I have an
application that is retrieving "uptime" (an integer number of seconds since
reboot) and recasting it as varchar and then interval type.  For example,

 select (1824459::varchar)::interval;

Which in previous versions of Postgres returned '21 days 02:47:39'.  If I
use "justify_hours" the application will not run on older versions of
Postgres, and will not be portable to other DBs.  I thought perhaps some
"datestyle" setting was different or some other factor that I was
overlooking.  I am trying to find a generic way to get the same output on
newer versions of PostgreSQL.

Thanks,
Linda

>             regards, tom lane
>

--
Linda Gray
Unitrends Corporation
803.454.0300 ext. 241

pgsql-general by date:

Previous
From: Martijn van Oosterhout
Date:
Subject: Re: What's a good default encoding?
Next
From: Tony Caduto
Date:
Subject: Only 6 days left to get PGLA for 5 dollars (promtion has been adjusted to 100 units)