CALCULAR EDAD!

From: "juan jose dominguez" <preguntas_sql(at)hotmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: CALCULAR EDAD!
Date: 2006-04-27 17:56:41
Message-ID: BAY23-F11BB31AA70A23C10E2214A83BD0@phx.gbl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

<html><div style='background-color:'><DIV>
<DIV class=RTE>Buenas, queria saber como sacar la edad de alguien. Me da el siguiente error con el siguiente codigo : </DIV>
<DIV></DIV>
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
<H5>-- Function: funcion_saca_edad() </H5>
<H5>DROP TRIGGER trigger_saca_edad ON fechas; </H5>
<H5>DROP FUNCTION funcion_saca_edad (); </H5>
<H5>CREATE OR REPLACE FUNCTION funcion_saca_edad() RETURNS OPAQUE AS' </H5>
<H5>DECLARE </H5>
<H5>edad timestamp; </H5>
<H5>BEGIN </H5>
<H5>edad := age(CURRENT_DATE,NEW.fecha); </H5>
<H5>RAISE NOTICE ''edad : %'',edad; </H5>
<H5>RAISE NOTICE ''32131231''; </H5>
<H5>RETURN NEW; </H5>
<H5>END; </H5>
<H5>'LANGUAGE 'plpgsql'; </H5>
<H5>CREATE TRIGGER trigger_saca_edad BEFORE INSERT OR UPDATE ON fechas </H5>
<H5>FOR EACH ROW EXECUTE PROCEDURE funcion_saca_edad (); </H5></BLOCKQUOTE>
<DIV></DIV>
<DIV></DIV>
<DIV></DIV>INSERT INTO fechas VALUES ('10/07/83');
<DIV></DIV>
<DIV></DIV>
<DIV></DIV>ERROR:&nbsp;&nbsp;invalid input syntax for type timestamp: "22 years 6 mons 20 days"
<DIV></DIV>CONTEXT:&nbsp;&nbsp;PL/pgSQL function "funcion_saca_edad" line 6 at assignment
<DIV></DIV>
<DIV></DIV>
<DIV></DIV></DIV></div><br clear=all><hr>Tu horóscopo diario, semanal y gratuito. <a href="http://g.msn.com/8HMAESES/2728??PS=47575" target="_top">Cartas, tarot y predicciones en MSN Horóscopo</a> </html>

Attachment Content-Type Size
unknown_filename text/html 1.3 KB

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Andreas Kretschmer 2006-04-27 18:05:31 Re: CALCULAR EDAD!
Previous Message Jim Buttafuoco 2006-04-27 17:40:02 Re: query that needs two nested queries, is this the best way?