Re: bigint and unix time

From: Adrian Klaver <adrian(dot)klaver(at)gmail(dot)com>
To: Janiv Ratson <yanivra(at)essence-grp(dot)com>
Cc: "pgsql-sql(at)postgresql(dot)org" <pgsql-sql(at)postgresql(dot)org>
Subject: Re: bigint and unix time
Date: 2011-08-16 13:43:54
Message-ID: 201108160643.54672.adrian.klaver@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Tuesday, August 16, 2011 2:12:52 am Janiv Ratson wrote:
> Hi Adrain and thank you,
> Trac 0.12 uses microseconds as time value.
> What do you suggest?

extract(epoch ..) returns seconds which you are trying to compare to
microseconds. The solution would be to divide your 'time' values by 1,000,000 to
make them seconds. Like:

SELECT ticket, "time"/1000000, author, field, oldvalue, newvalue
FROM ticket_change
where "time"/1000000
BETWEEN
extract(epoch from (date 'now' - integer '30')) AND
extract(epoch from (date 'now'));

>
> Thanks,
> Janiv.
>

--
Adrian Klaver
adrian(dot)klaver(at)gmail(dot)com

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message David Johnston 2011-08-16 14:06:56 Re: which is better: using OR clauses or UNION?
Previous Message Viktor Bojović 2011-08-16 11:56:34 Re: which is better: using OR clauses or UNION?