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: Gunnar Wolf <gwolf(at)gwolf(dot)org>, Lista PostgreSql <pgsql-es-ayuda(at)postgresql(dot)org>
Subject: Re: convertir fecha a interval definido
Date: 2011-02-11 10:27:30
Message-ID: 4D550F12.3050405@usit.uio.no
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-es-ayuda

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Miguel Angel Hernandez Moreno wrote:

>
> $ SELECT EXTRACT( epoch FROM ( '1970-01-01'::timestamp +
> ( '2011-02-10 15:56:39'::timestamp -
> '2011-02-02 15:56:39'::timestamp)));
> date_part
> -----------
> 712800
> (1 row)
>

El intervalo entre '2011-02-10 15:56:39' y '2011-02-02 15:56:39' es 8
dias, o lo que es lo mismo 691200 segundos.

El comando sql de arriba no da el resultado correcto. Segun la
documentacion, EXTRACT(EPOCH FROM INTERVAL) nos da el numero exacto de
segundos en el intervalo definido.

Este comando retorna el numero de segundos exactos:

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

- --
Rafael Martinez, <r(dot)m(dot)guerrero(at)usit(dot)uio(dot)no>
Center for Information Technology Services
University of Oslo, Norway

PGP Public Key: http://folk.uio.no/rafael/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)

iEYEARECAAYFAk1VDxIACgkQBhuKQurGihTsZwCeJ1MDCb/XPfrskl1+joWTd22S
JtEAmwaKYn/JEjybn0YAik6mS49eoiH6
=OaLJ
-----END PGP SIGNATURE-----

In response to

Responses

Browse pgsql-es-ayuda by date

  From Date Subject
Next Message Cristian Herrera 2011-02-11 13:29:39 Postgres y Versiones.
Previous Message Miguel Angel Hernandez Moreno 2011-02-11 02:33:21 Re: convertir fecha a interval definido