Re: SELECT timestamp('2001-06-12'::date - '2000-06-12'::date) - Mailing list pgsql-sql

From Tom Lane
Subject Re: SELECT timestamp('2001-06-12'::date - '2000-06-12'::date)
Date
Msg-id 22460.989723036@sss.pgh.pa.us
Whole thread Raw
In response to SELECT timestamp('2001-06-12'::date - '2000-06-12'::date)  (Hans-Jürgen Schönig <hs@cybertec.at>)
List pgsql-sql
Hans-Jürgen Schönig <hs@cybertec.at> writes:
> Surprisingly "-" is defined for (date, date).

What's surprising about that?  It yields an integer number of days
between the dates:

regression=# select '2001-06-12'::date - '2000-06-12'::date;?column?
----------     365
(1 row)

> performance=# SELECT timestamp('2001-06-12'::date - '2000-06-12'::date);

>        timestamp
> ------------------------
>  1970-01-01 01:06:05+01
> (1 row)

timestamp(integer) converts a Unix timestamp value (seconds since 1970)
into a timestamp.
        regards, tom lane


pgsql-sql by date:

Previous
From: Tom Lane
Date:
Subject: Re: can't get rid of unnesesary SORT step in explain plan for hash join
Next
From: "Marc Lamothe"
Date:
Subject: Problem using IP functions