Re: extracting time from a timestamp with time zone field

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Peter Nixon <listuser(at)peternixon(dot)net>
Cc: Andy Kriger <akriger(at)greaterthanone(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: extracting time from a timestamp with time zone field
Date: 2003-04-08 23:24:48
Message-ID: 20030408232447.GB15928@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, Apr 08, 2003 at 11:38:38AM +0300, Peter Nixon wrote:
> date_truc seems to only lower precision which is not what I want.
> For instance if the value in my TIMESTAMP field is:
> 2001-02-16 20:38:40
> I want a function that outputs:
> 20:38:40
> ie the time, WITHOUT the date part of the field.

Just cast it:
# select cast('2001-02-16 20:38:40'::timestamp as time);
?column?
----------
20:38:40
(1 row)

--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> "the West won the world not by the superiority of its ideas or values or
> religion but rather by its superiority in applying organized violence.
> Westerners often forget this fact, non-Westerners never do."
> - Samuel P. Huntington

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Martijn van Oosterhout 2003-04-08 23:34:50 Re: Live Link to Oracle?
Previous Message Joe Conway 2003-04-08 22:57:09 Re: Covariance Function in Postgresql??