Re: Help with SQL updating not working.

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Paul Linehan <linehanp(at)tcd(dot)ie>
Cc: "pgsql-novice(at)postgresql(dot)org" <pgsql-novice(at)postgresql(dot)org>
Subject: Re: Help with SQL updating not working.
Date: 2015-05-18 22:24:12
Message-ID: CAKFQuwayy0KcAhaKDv4wpaALBPLcJXk040UMXxkZ7LGBwuFhVQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On Mon, May 18, 2015 at 1:27 PM, Paul Linehan <linehanp(at)tcd(dot)ie> wrote:

>
> Now, into the time_diff field, I want to insert the time difference in
> seconds
>
> I've tried various combinations of this
>
> update the_times as set time_diff = extract ('epoch' from
> (the_times.time2 - the_times.time1)::interval) from the_times;
>
> but to no avail.
>
> Could any kind soul help me out on this?
> ​​
>


SELECT extract('epoch' FROM te) - extract('epoch' FROM ts)
FROM (
VALUES ( '08:34:21'::time, '09:34:21'::time)
) tm (ts, te)

epoch ARE seconds; just subtract them directly.

David J.

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Andreas Kretschmer 2015-05-19 06:23:51 Re: Help with SQL updating not working.
Previous Message Daniel Begin 2015-05-18 21:22:37 Re: Moving Database Cluster to another drive