From: | "Jaime Casanova" <systemguards(at)gmail(dot)com> |
---|---|
To: | "Guillermo Munoz" <munozgb(at)gmail(dot)com> |
Cc: | Javier Bermúdez Tito <javier_bt(at)hotmail(dot)com>, "Ayuda Postgres PostgreSQL" <pgsql-es-ayuda(at)postgresql(dot)org> |
Subject: | Re: Calcular Numero de Meses |
Date: | 2007-12-18 05:16:30 |
Message-ID: | c2d9e70e0712172116we634d0dp5076f59212745d53@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-es-ayuda |
On Dec 17, 2007 2:27 PM, Guillermo Munoz <munozgb(at)gmail(dot)com> wrote:
>
> > hola listeros, tengo un casito que necesito resolver con urgencia haber si
> > alguien me puede ayudar gracias.
> > El tema es el siguiente, necesito obtener el numero de meses transcurridos
> > apartir de un rando de fechas por ejemplo
> >
> > El resultado en Meses
> >
> > 01/01/2007 <-> 31/12/2007 ==> 12
> >
> > 01/01/2007 <-> 05/02/2007 ==> 13
> >
> > 01/01/2007 <-> 01/03/2007 ==> 14
> >
dudaria de esta matematica tuya ;)
> > que no me convierta el resultado en años, ojala me deje entender y alguien
> > me pueda ayudar gracias
> >
>
> funcion age(timestamp, timestamp) y a eso hacele date_part('month',
> age(timestamp, timestamp))
>
no porque si la respuesta es 1 año 1 mes, lo que Javier quiere es que
salga 13... y lo que tu sugieres te daria 1
mejor prueba esto:
postgres=# select (date_part('year', age) * 12) + date_part('month', age)
postgres=# from (select age('2007-02-05'::date, '2006-01-01'::date)) foodate;
?column?
----------
13
(1 row)
--
Atentamente,
Jaime Casanova
"Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs and the universe trying
to produce bigger and better idiots.
So far, the universe is winning."
Richard Cook
From | Date | Subject | |
---|---|---|---|
Next Message | Johnny Verdugo | 2007-12-18 12:37:32 | 208000 insert en archivo sql no permite postgre |
Previous Message | Gabriel Hermes Colina Zambra | 2007-12-18 00:50:40 | Re: Orientacion sobre eleccion de servidor para este sistema |