Re: [SQL] time intervals

From: Mark Jewiss <mark(at)office(dot)knowledge(dot)com>
To: JT Kirkpatrick <jt-kirkpatrick(at)mpsllc(dot)com>
Cc: "'pgsql-sql(at)hub(dot)org'" <pgsql-sql(at)hub(dot)org>
Subject: Re: [SQL] time intervals
Date: 1999-04-30 08:10:00
Message-ID: Pine.BSF.4.05.9904300905520.10443-100000@office.knowledge.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message George Moga 1999-04-30 09:53:13 Re: [SQL] time intervals
Previous Message Christophe Labouisse 1999-04-30 05:19:33 [SQL] Index on date_trunc