Обсуждение: Getting time from date field

Поиск
Список
Период
Сортировка

Getting time from date field

От
Alejandro Javier Pomeraniec
Дата:
Hi !

Is there any way to get the time like the following example ?

'2003-05-11 15:21:21'

should return

'15:21:21'


Thanks !!

Re: Getting time from date field

От
Bruno Wolff III
Дата:
On Wed, Nov 05, 2003 at 17:12:12 +0000,
  Alejandro Javier Pomeraniec <apomeraniec@buenosaires.gov.ar> wrote:
> Hi !
>
> Is there any way to get the time like the following example ?
>
> '2003-05-11 15:21:21'
>
> should return
>
> '15:21:21'

You can use the to_char function to convert timestamps to text with
control over the output format.

Re: Getting time from date field

От
Alvaro Herrera
Дата:
On Wed, Nov 05, 2003 at 05:12:12PM +0000, Alejandro Javier Pomeraniec wrote:

> Is there any way to get the time like the following example ?
>
> '2003-05-11 15:21:21'
>
> should return
>
> '15:21:21'

Cast it to time:

regression=# SELECT '2003-05-11 15:21:21'::time;
   time
----------
 15:21:21
(1 fila)

--
Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
"No necesitamos banderas
No reconocemos fronteras"                  (Jorge González)