Re: Diferencia de tiempo

From: Julio Cesar Rodriguez Dominguez <jurasec(at)gmail(dot)com>
To: Miguel Angel <mvillagomez(at)sayab(dot)com(dot)mx>
Cc: Lista Postgres <pgsql-es-ayuda(at)postgresql(dot)org>
Subject: Re: Diferencia de tiempo
Date: 2009-05-20 15:07:02
Message-ID: 925902880905200807o4e0f841bv87c80ceb06d57e7a@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-es-ayuda

El 20 de mayo de 2009 10:05, Miguel Angel <mvillagomez(at)sayab(dot)com(dot)mx>escribió:

> El mié, 20-05-2009 a las 09:54 -0500, Julio Cesar Rodriguez Dominguez
> escribió:
> > Podrias hacer uso de la función age, pero antes tienes que convertir
> > tus fechas para ponerlas al dia de inicio del mes, por ejemplo:
> >
> > postgres(at)test[localhost]=# select age(date '2009-01-01', date
> > '2008-12-01');
> > age
> > -------
> > 1 mon
> > (1 fila)
> >
> > postgres(at)test[localhost]=# select age(date '2010-01-01', date
> > '2008-12-01');
> > age
> > --------------
> > 1 year 1 mon
> > (1 fila)
> >
> > postgres(at)test[localhost]=# select age(date '2009-02-01', date
> > '2008-12-01');
> > age
> > --------
> > 2 mons
> > (1 fila)
> >
> > postgres(at)test[localhost]=# select age(date '2011-05-01', date
> > '2008-02-01');
> > age
> > ----------------
> > 3 years 3 mons
> > (1 fila)
> >
> > Solo faltaria hacer la converisión de años a meses.
>
> Muchas gracias por la ayuda, yo creo que con esto ya puedo hacerlo
> perfectamente, solo trabajaré en la conversión de años a meses, gracias
> a todos.
>
>
quedaria algo asi:
postgres(at)test[localhost]=# select extract(years from age(date '2011-05-01',
date '2008-02-01')) * 12 +
extract(months from age(date '2011-05-01', date '2008-02-01'));

Saludos.

In response to

Browse pgsql-es-ayuda by date

  From Date Subject
Next Message Alvaro Herrera 2009-05-20 15:12:30 Re: The database cluster was initialized without HAVE_INT64_TIMESTAMP
Previous Message Miguel Angel 2009-05-20 15:05:10 Re: Diferencia de tiempo