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

Re: convertir fecha a interval definido

From: Rafael Martinez <r(dot)m(dot)guerrero(at)usit(dot)uio(dot)no>
To: Miguel Angel Hernandez Moreno <miguel(dot)hdz(dot)mrn(at)gmail(dot)com>
Cc: Lista PostgreSql <pgsql-es-ayuda(at)postgresql(dot)org>
Subject: Re: convertir fecha a interval definido
Date: 2011-02-10 22:41:18
Message-ID: 1297377678.2710.4.camel@core2 (view raw or flat)
Thread:
Lists: pgsql-es-ayuda
On Thu, 2011-02-10 at 15:59 -0600, Miguel Angel Hernandez Moreno wrote:
> saludos lista
> 
> e tenido una pregunta, es posible hacer una resta de fecha pero
> definir en que queremos el interval
> 
> select ('2011-02-10 15:56:39'::timestamp - '2011-02-02
> 15:56:39'::timestamp)::interval ('seconds')
> 
> de que manera se podria hacer??
> 

Usa EXTRACT(EPOCH FROM INTERVAL). Te quedaria asi:

select EXTRACT(EPOCH FROM('2011-02-10 15:56:39'::timestamp - '2011-02-02
15:56:39'::timestamp)::interval);

Mas informacion en:
http://www.postgresql.org/docs/current/interactive/functions-datetime.html

-- 
Rafael Martinez <r(dot)m(dot)guerrero(at)usit(dot)uio(dot)no>
University of Oslo

In response to

pgsql-es-ayuda by date

Next:From: Gunnar WolfDate: 2011-02-10 22:43:09
Subject: Re: convertir fecha a interval definido
Previous:From: Miguel Angel Hernandez MorenoDate: 2011-02-10 21:59:04
Subject: convertir fecha a interval definido

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