Re: date question

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: javier garcia - CEBAS <rn001(at)cebas(dot)csic(dot)es>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, "pgsql-sql(at)postgresql(dot)org" <pgsql-sql(at)postgresql(dot)org>
Subject: Re: date question
Date: 2003-06-22 11:35:59
Message-ID: 20030622113559.GA10247@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Fri, Jun 20, 2003 at 19:33:35 +0200,
javier garcia - CEBAS <rn001(at)cebas(dot)csic(dot)es> wrote:
> 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;

It would probably be better to use a view instead of copying the data
to another table. That way you don't need to worry about the data
getting out of sync.

> 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.

It wouldn't be because of trying to compare a date and an interval.
You would get an error message instead.

> 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)

Not really. You could add the interval values to a base date, but that may
or may not make sense depending on your application.

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message btober 2003-06-22 12:45:22 Informing end-user of check constraint rules
Previous Message Paul Thomas 2003-06-22 11:03:35 Re: Delete duplicates