pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedAbout intervals
2+ messages / 2 participants
[nested] [flat]
* About intervals
@ 2004-05-28 18:27 Pablo Velasquez Rivas <pvelasquez@its.co.cr>
0 siblings, 1 reply; 2+ messages in thread
From: Pablo Velasquez Rivas @ 2004-05-28 18:27 UTC (permalink / raw)
To: pgsql-sql
Hi all.
I have a table with some timestamps fields. For example this table:
* date1 | date2
-----------------------------+---------------------------
2004-03-01 11:20:00 | 2004-03-01 11:55:00*
If I do a query like this, I get:
/ SELECT date2 - date1 as diff FROM table/;
* diff
-------
00:35
(1 row)
*
but if I do a query like this, I get:
/ SELECT date2 - date1 as diff FROM table WHERE date2 - date1 >=
interval '15:00';/
* diff
------
(0 rows)
*
What can I do to do a query like the previous one , and get the right
answer??
Thanks !!
--
== ==
Pablo A. Velasquez Rivas
Computer Science Engineer
== ==
/ All programmers are optimists / -- Frederick P. Brooks, Jr.
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: About intervals
@ 2004-05-28 21:23 Bruno Wolff III <bruno@wolff.to>
parent: Pablo Velasquez Rivas <pvelasquez@its.co.cr>
0 siblings, 0 replies; 2+ messages in thread
From: Bruno Wolff III @ 2004-05-28 21:23 UTC (permalink / raw)
To: Pablo Velasquez Rivas <pvelasquez@its.co.cr>; +Cc: pgsql-sql
On Fri, May 28, 2004 at 12:27:53 -0600,
Pablo Velasquez Rivas <pvelasquez@its.co.cr> wrote:
>
> but if I do a query like this, I get:
> / SELECT date2 - date1 as diff FROM table WHERE date2 - date1 >=
> interval '15:00';/
> * diff
> ------
> (0 rows)
> *
> What can I do to do a query like the previous one , and get the right
> answer??
It looks like 15:00 is being taking to mean 15 hours 0 minutes.
The more normal syntax for specifying 15 minutes is '15 minutes.
So you probably want:
SELECT date2 - date1 as diff FROM table WHERE date2 - date1 >= interval
'15 minutes';
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2004-05-28 21:23 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2004-05-28 18:27 About intervals Pablo Velasquez Rivas <pvelasquez@its.co.cr>
2004-05-28 21:23 ` Bruno Wolff III <bruno@wolff.to>
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