Re: SELECT timestamp('2001-06-12'::date - '2000-06-12'::date)

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Hans-Jürgen Schönig <hs(at)cybertec(dot)at>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: SELECT timestamp('2001-06-12'::date - '2000-06-12'::date)
Date: 2001-05-13 03:03:56
Message-ID: 22460.989723036@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

=?iso-8859-1?Q?Hans=2DJ=FCrgen=20Sch=F6nig?= <hs(at)cybertec(dot)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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2001-05-13 03:44:24 Re: Problem using IP functions
Previous Message Tom Lane 2001-05-13 01:53:56 Re: can't get rid of unnesesary SORT step in explain plan for hash join