pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Mark Jewiss <mark@office.knowledge.com>
To: JT Kirkpatrick <jt-kirkpatrick@mpsllc.com>
Cc: 'pgsql-sql@hub.org' <pgsql-sql@hub.org>
Subject: Re: [SQL] time intervals
Date: Fri, 30 Apr 1999 09:10:00 +0100 (BST)
Message-ID: <Pine.BSF.4.05.9904300905520.10443-100000@office.knowledge.com> (raw)
In-Reply-To: <01BE925B.352BE160.jt-kirkpatrick@mpsllc.com>

> 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




view thread (9+ messages)  latest in thread

Message-ID: <Pine.BSF.4.05.9904300905520.10443-100000@office.knowledge.com>
Permalink:  ../Pine.BSF.4.05.9904300905520.10443-100000@office.knowledge.com/
Also on:    postgresql.org/message-id/Pine.BSF.4.05.9904300905520.10443-100000@office.knowledge.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: mark@office.knowledge.com, jt-kirkpatrick@mpsllc.com, pgsql-sql@hub.org
  Subject: Re: [SQL] time intervals
  In-Reply-To: <Pine.BSF.4.05.9904300905520.10443-100000@office.knowledge.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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