Skip site navigation (1) Skip section navigation (2)

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 (view raw, whole thread or download thread mbox)
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() []: 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



More than messages–check out the rest of the Windows Live™.


pgsql-es-ayuda by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group