pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Hans-Jürgen Schönig <hs@cybertec.at>
To: pgsql-sql@postgresql.org
Subject: SELECT timestamp('2001-06-12'::date - '2000-06-12'::date)
Date: Sat, 12 May 2001 21:26:45 +0200
Message-ID: <3AFD8E75.A1E5115B@cybertec.at> (raw)

The "+" operator is not defined for (date, date) which seems very
logical to me since adding dates does in my opinion not make sense.
performance=# SELECT timestamp('2001-06-12'::date + '2000-06-12'::date);

ERROR:  Unable to identify an operator '+' for types 'date' and 'date'
        You will have to retype this query using an explicit cast

Surprisingly "-" is defined for (date, date).
performance=# SELECT timestamp('2001-06-12'::date - '2000-06-12'::date);

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

Does anybody understand the logic behind that operation and why is the
result not something like 1970-01-01 00:00:00?

    Hans




view thread (2+ messages)  latest in thread

Message-ID: <3AFD8E75.A1E5115B@cybertec.at>
Permalink:  ../3AFD8E75.A1E5115B@cybertec.at/
Also on:    postgresql.org/message-id/3AFD8E75.A1E5115B@cybertec.at

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: hs@cybertec.at
  Subject: Re: SELECT timestamp('2001-06-12'::date - '2000-06-12'::date)
  In-Reply-To: <3AFD8E75.A1E5115B@cybertec.at>
  References: <3AFD8E75.A1E5115B@cybertec.at>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox