Re: [SQL] Time related question...

Patrice Hédé <patrice@idf.net>

From: Patrice Hédé <patrice@idf.net>
To: Kevin Colagio <kcolagio@wc.eso.mc.xerox.com>
Cc: pgsql-sql@postgreSQL.org
Date: 1998-06-17T12:45:15Z
Lists: pgsql-sql
On Wed, 17 Jun 1998, Kevin Colagio wrote:

> 
> I have a database that tracks the service calls we do.  In the database
> are abstime values for:
>   dateentered
>   dateclosed
>   dateassigned
>   datecontacted

Can't you design it with 'datetime' fields instead, which is much better
handled ? then, you would be able to do exactly what you want !

> My question is: what is the SQL statement that will allow me to find:
>   1) a list of the calls where the difference between the dateentered and
>   dateclosed is less than (say) 3 days.
> 
> I have tried:
>   Select * from servicecall where (dateentered <#> dateclosed) #<= 3 days;
>   Select * from servicecall where (dateclosed  - dateentered) #<= 3 days;
>   Select * from servicecall where (dateentered <#> dateclosed) #<= @3 days;
>   Select * from servicecall where (dateclosed  - dateentered) #<= @3 days;

with datetime, it could be then :

select * from servicecall whre (dateclosed - dateentered) < '3 days';

However, if you really need abstime, I don't know the answer.

Hope this helps

Patrice

--
Patrice HÉDÉ --------------------------------- patrice@idf.net -----
... Ásólfr hljóp upp á skip Hrúts  ok varð fjögurra manna bani,  áðr
Hrútr varð varr við. Sneri hann þá í móti honum. En er þeir fundust,
lagði Ásólfr í skjöld Hrúts ok í gegnum, en Hrútr hjó til Ásólfs, ok
varð þat banahögg.                                    --- Njáls Saga
----- http://www.idf.net/patrice/ ----------------------------------