Re: From timestamp to seconds since epoch?

From: Thomas Lockhart <lockhart(at)alumni(dot)caltech(dot)edu>
To: Erich <hh(at)cyberpass(dot)net>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: From timestamp to seconds since epoch?
Date: 2000-07-18 02:05:46
Message-ID: 3973BB7A.AAC5F552@alumni.caltech.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> I've read through all the documentation, and I can't find a function
> that takes a timestamp and converts iit to seconds since epoch.

That would be date_part('epoch', ts) ...

> Here's what I need to do: I have pairs of timestamps ('2000-07-12
> 03:33:53+00'), and I want to find out how many seconds are in the
> interval between them. I know I can do
> select timestamp1 - timestamp2
> and I get a result in days, hours, mins, and seconds, but is there a
> way to get that whole thing in just seconds? This has to be pretty
> efficient, because it's going to get called a lot.

... and that would be date_part('epoch', ts1 - ts2)

- Thomas

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Chris Bitmead 2000-07-18 02:10:07 Re: MOD
Previous Message Erich 2000-07-18 01:21:53 From timestamp to seconds since epoch?