Re: [SQL] time intervals - Mailing list pgsql-sql

From Mark Jewiss
Subject Re: [SQL] time intervals
Date
Msg-id Pine.BSF.4.05.9904300905520.10443-100000@office.knowledge.com
Whole thread Raw
In response to time intervals  (JT Kirkpatrick <jt-kirkpatrick@mpsllc.com>)
List pgsql-sql
> I have two fields, timein & timeout, both defined as type "time".  how can 
> i get the difference between the two??  i am connecting to postgres through 
> access97 and trying to run a simple query to show me timeout, timein, and 
> timeout-timein, but the calculation is returning an error.

In SQL you can do a DATEDIFF...I'm not in front of postgresql so am not
sure if it supports this.

Syntax is

select datediff (day, mydate, 'Jan 10 1999'
from table

If mydate = Jan 9, then the result is one. I think datediff accepts
datetime, so if you specify it properly (i.e. '1 Jan 1999 10:05") then
you'll get the right answers. Just change day to whatever you need.

Regards,

Mark.
--
Mark Jewiss
Knowledge Matters Limited



pgsql-sql by date:

Previous
From: Christophe Labouisse
Date:
Subject: [SQL] Index on date_trunc
Next
From: George Moga
Date:
Subject: Re: [SQL] time intervals