consulta de campos con fechas

From: Jhonny Velasquez c(dot) <jhon_vels(at)hotmail(dot)com>
To: <pgsql-es-ayuda(at)postgresql(dot)org>
Subject: consulta de campos con fechas
Date: 2009-03-31 15:25:35
Message-ID: SNT102-W62C2CB3A0571FB045D6BD99F8A0@phx.gbl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-es-ayuda


puedo hacer esta consulta en postgres?

son campos de tipo date, de los cuales quiero extaer el mes y año directamente en la consulta sql.

el formato es 2007-07-04

$sql=pg_query($link,"SELECT MONTH(ps.iniciogestion) AS mesinicio, YEAR(ps.iniciogestion) AS anioinicio, DATEDIFF(ps.iniciogestion,ps.finalgestion) AS duracion, MONTH(ps.finalgestion) AS mesfinal, YEAR(ps.finalgestion) AS aniofinal FROM programasedes AS ps");

pero me da este error

Warning: pg_query() [function.pg-query]: Query failed: ERROR: function month(date) does not exist LINE 1: ...MONTH(ps.i... ^ HINT: No function matches the given name and argument types. You might need to add explicit type casts. in E:\AppServ\www\finanzas\includes\sqldatabase.php on line 37

saludos y gracias por su tiempo

Jhonvels

_________________________________________________________________
More than messages–check out the rest of the Windows Live™.
http://www.microsoft.com/windows/windowslive/

Responses

Browse pgsql-es-ayuda by date

  From Date Subject
Next Message Jaime Casanova 2009-03-31 15:41:46 Re: consulta de campos con fechas
Previous Message marcelo Cortez 2009-03-30 20:20:58 Re: optimizar consulta