X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.193]) by svr1.postgresql.org (Postfix) with ESMTP id 2560E30EAE9 for ; Fri, 20 Jun 2003 17:34:04 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (svr1.postgresql.org [64.117.224.193]) (amavisd-new, port 10024) with ESMTP id 79988-04 for ; Fri, 20 Jun 2003 14:33:53 -0300 (ADT) Received: from natura.cebas.csic.es (natura.cebas.csic.es [161.111.146.9]) by svr1.postgresql.org (Postfix) with ESMTP id B3AC330EA19 for ; Fri, 20 Jun 2003 14:33:52 -0300 (ADT) Received: from natura.cebas.csic.es (localhost.localdomain [127.0.0.1]) by natura.cebas.csic.es (8.11.6/8.11.6) with ESMTP id h5KHJqo10120 for ; Fri, 20 Jun 2003 19:19:52 +0200 Received: from there (equipo97.cebas.csic.es [161.111.146.97]) by natura.cebas.csic.es (8.11.6/8.11.6) with SMTP id h5KHJpI10111; Fri, 20 Jun 2003 19:19:51 +0200 Message-Id: <200306201719.h5KHJpI10111@natura.cebas.csic.es> Content-Type: text/plain; charset="iso-8859-1" From: javier garcia - CEBAS Organization: CEBAS-CSIC To: Peter Eisentraut Subject: Re: date question Date: Fri, 20 Jun 2003 19:33:35 +0200 X-Mailer: KMail [version 1.3.2] References: In-Reply-To: Cc: "pgsql-sql@postgresql.org" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Archive-Number: 200306/237 X-Sequence-Number: 13995 Hi all; Peter, thank you very much for your help. Just a little thing. I've done as you say: CREATE TABLE rain_series_dated AS SELECT (year * interval '1 year' + month * interval '1 month' + day * interval '1 day') AS fecha,est7237,est7238,est7239,est7250 FROM rain_series ORDER by fecha; I see that the obtained new field is "interval" type: Column | Type | Modifiers ---------+----------+----------- fecha | interval | est7237 | real | est7238 | real | .... And I've tried to use this result to be compared with my other table in which "fecha" is "date" type. The result is that the query halts with no result; I guess that it is because it tries to compare different data types. Is it possible to cast the "interval" obtained type into a "date" one in the creation of the mentioned table? (I've looked it in the documentation, but I can't find the answer) Thanks and regards, Javier ............................ El Mar 17 Jun 2003 20:09, escribió: > javier garcia - CEBAS writes: > > Is there a way to create a table from this table, directly in Postgres in > > which a date field is created based in the values of "year", "month", > > "day" in this table? >------------------------------------------------------------------------------------------------------------------ > year * interval '1 year' + month * interval '1 month' + day * interval '1 > day' > > This results in a timestamp value that you can compare to or assign to a > date value.