According to the SQL standard, shouldn't this work? select '506:47:04'::interval day to second ; Is there a portable way to do this without using justify_hours()? - Thanks On Tuesday 14 March 2006 6:58 pm, Michael Glaesemann wrote: > You will get better, faster answers by sending questions to a > PostgreSQL mailing list. By emailing me directly you may not get a > timely response if I don't have time to answer. Others can then > answer and learn from the subsequent discussion. I'm ccing this to > pgsql-general. > > On Mar 15, 2006, at 6:45 , Linda wrote: > > > Hi, Michael > > > > I have a question about the output format of the INTERVAL type in > > version > > 8.1.1. In previous versions, I could do the following: > > > > select (uptime::varchar)::interval from machine_info; > > > > where uptime is an INTEGER type, the number of seconds the machine > > has been > > up since last reboot. This used to produce output in this format: > > 21 days 02:47:04 > > > > Now in v8.1.1, the output format is > > 506:47:04 > > > > How can I get the "justified" output as before? Is there some > > setting of > > datestyle that affects the output? I have tried specifying > > "interval day > > to second" but that doesn't work. Using the new justify_hours > > function > > works, but is it possible to do something that will run on older > > versions > > of postgresql? > > > > Thanks, > > Linda > > > > -- > > Linda Gray > > Unitrends Corporation > > 803.454.0300 ext. 241 > > > > justify_hours is also in 8.1 and should do what you want. > > test=# select '506:47:04'::interval; > interval > ----------- > 506:47:04 > (1 row) > > test=# select justify_hours('506:47:04'::interval); > justify_hours > ------------------ > 21 days 02:47:04 > (1 row) > > test=# select version(); > > version > ------------------------------------------------------------------------ > ---------------------------------------------------------------------- > PostgreSQL 8.1.3 on powerpc-apple-darwin8.4.0, compiled by GCC > powerpc-apple-darwin8-gcc-4.0.1 (GCC) 4.0.1 (Apple Computer, Inc. > build 5247) > (1 row) > > > Michael Glaesemann > grzm myrealbox com > > > > -- Linda Gray Unitrends Corporation 803.454.0300 ext. 241