pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedSELECT timestamp('2001-06-12'::date - '2000-06-12'::date)
2+ messages / 2 participants
[nested] [flat]
* SELECT timestamp('2001-06-12'::date - '2000-06-12'::date)
@ 2001-05-12 19:26 Hans-Jürgen Schönig <hs@cybertec.at>
0 siblings, 1 reply; 2+ messages in thread
From: Hans-Jürgen Schönig @ 2001-05-12 19:26 UTC (permalink / raw)
To: pgsql-sql
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
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: SELECT timestamp('2001-06-12'::date - '2000-06-12'::date)
@ 2001-05-13 03:03 Tom Lane <tgl@sss.pgh.pa.us>
parent: Hans-Jürgen Schönig <hs@cybertec.at>
0 siblings, 0 replies; 2+ messages in thread
From: Tom Lane @ 2001-05-13 03:03 UTC (permalink / raw)
To: Hans-Jürgen Schönig <hs@cybertec.at>; +Cc: pgsql-sql
=?iso-8859-1?Q?Hans=2DJ=FCrgen=20Sch=F6nig?= <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
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2001-05-13 03:03 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-05-12 19:26 SELECT timestamp('2001-06-12'::date - '2000-06-12'::date) Hans-Jürgen Schönig <hs@cybertec.at>
2001-05-13 03:03 ` Tom Lane <tgl@sss.pgh.pa.us>
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