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

Re: [NOVICE] Re: Interval output format

From: "Oliver Elphick" <olly(at)lfix(dot)co(dot)uk>
To: pgsql-novice(at)postgresql(dot)org
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: [NOVICE] Re: Interval output format
Date: 2001-01-19 00:02:41
Message-ID: 200101190002.f0J02kq01968@linda.lfix.co.uk (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-novice
"Stefan Waidele jun." wrote:
  >At 13:37 18.01.2001 -0500, Tom Lane wrote:
  >>"Stefan Waidele jun." <St(dot)Waidele(dot)jun(at)Krone-Neuenburg(dot)de> writes:
  >> > How can I tell Postgres to return an interval value in an format like 
  >> hhh:mm?
  >>
  >>See to_char(),
  >>http://www.postgresql.org/devel-corner/docs/postgres/functions-formatting.h
      >tm

to_char() can't take an interval, even in 7.1:

bray=# select proname,pronargs,proargtypes from pg_proc where proname = 'to_char';
 proname | pronargs | proargtypes 
---------+----------+-------------
 to_char |        2 |       20 25
 to_char |        2 |       23 25
 to_char |        2 |      700 25
 to_char |        2 |      701 25
 to_char |        2 |     1184 25
 to_char |        2 |     1700 25
(6 rows)

and date_part() merely extracts the requested part, thus losing data:

bray=#  select date_part('hour','3 days 10:23'::INTERVAL);
 date_part 
-----------
        10
(1 row)

Can to_char be extended?
-- 
Oliver Elphick                                Oliver(dot)Elphick(at)lfix(dot)co(dot)uk
Isle of Wight                              http://www.lfix.co.uk/oliver
PGP: 1024R/32B8FAA1: 97 EA 1D 47 72 3F 28 47  6B 7E 39 CC 56 E4 C1 47
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839  932A 614D 4C34 3E1D 0C1C
                 ========================================
     "For the eyes of the LORD run to and fro throughout the
      whole earth, to show himself strong in the behalf of 
      them whose heart is perfect toward him..."            
                                   II Chronicles 16:9 



pgsql-novice by date

Next:From: Michael CaseDate: 2001-01-19 00:14:35
Subject: on re-starting i lost access to a database
Previous:From: Ken CoreyDate: 2001-01-18 23:56:47
Subject: Re: Yikes! Bitten by line length?

pgsql-hackers by date

Next:From: Thomas LockhartDate: 2001-01-19 00:53:52
Subject: Re: converting from text -> inet ... possible?
Previous:From: Peter EisentrautDate: 2001-01-18 23:48:06
Subject: Re: AW: AW: AW: AW: AW: Re: tinterval - operator problems o n AI X

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