Skip site navigation (1) Skip section navigation (2)

Re: Converting interval to numeric?

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: Sal Dkj <saldkj(at)hotmail(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Converting interval to numeric?
Date: 2005-02-11 04:58:25
Message-ID: 20050211045825.GA9313@wolff.to (view raw or flat)
Thread:
Lists: pgsql-novice
On Fri, Feb 11, 2005 at 01:48:06 +0000,
  Sal Dkj <saldkj(at)hotmail(dot)com> wrote:
> Hello, I'm trying to calculate the difference between two timestamps and 
> have the return value in minutes.
> 
> So, for instance:
> Time 1 = 1/1/2005 12:00
> Time 2 = 1/2/2005 12:00
> 
> If you subtract Time 1 from Time 2, it returns an interval value of '1 
> day'. Extracting hours or minutes from this obviously gives 0.  What's the 
>  trick here?

EXTRACT the EPOCH from the difference of the timestamps. This will give
you the elapsed times in seconds (as a float8 I think).

In response to

Responses

pgsql-novice by date

Next:From: Michael FuhrDate: 2005-02-11 07:13:26
Subject: Re: function returning a row
Previous:From: Mike G.Date: 2005-02-11 04:39:21
Subject: Re: PL/pgSQL: FOT Loops vs Cursors

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group