From: | Janiv Ratson <yanivra(at)essence-grp(dot)com> |
---|---|
To: | Adrian Klaver <adrian(dot)klaver(at)gmail(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 09:19:18 |
Message-ID: | 25B9D8D6D61CDB4CAD5D742B947F5C1A0493CC4F@ES-EX2010A-IL.essencesecurity.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Additional information:
If I use the following query:
select "time", extract(epoch from (date 'now' - integer '30')), extract(epoch from (date 'now'))
from ticket_change
The first row looks like this:
Bigint, double precision, double precision
1286090615000000;1310850000;1313442000
Thanks,
Janiv,
-----Original Message-----
From: Adrian Klaver [mailto:adrian(dot)klaver(at)gmail(dot)com]
Sent: Monday, August 15, 2011 17:14
To: Janiv Ratson
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: [SQL] bigint and unix time
On Sunday, August 14, 2011 11:23:08 pm Janiv Ratson wrote:
> Hi and thanks,
> If my 'time' column is being saved as bigint: 1287323899000000.
> How do I write a query to check if the 'time' field is greater than now -
> 30 (past 30 days)?
So what you want is not what values are greater than some point 30 days ago
which is what your previous query asked and answered, but the values between a
point 30 days ago and today. The easiest way is to use BETWEEN:
test(5432)aklaver=>\d big_int_test
Table "public.big_int_test"
Column | Type | Modifiers
--------+---------+-----------
bint | bigint |
rint | integer |
test(5432)aklaver=>SELECT * from big_int_test ;
bint | rint
------------------+------------
1287323899000000 | 1310799600
test(5432)aklaver=>SELECT
bint
FROM
big_int_test
WHERE
bint
BETWEEN
extract(epoch from (date 'now' - integer '30'))
AND
extract(epoch from (date 'now'));
bint
------
(0 rows)
That being said, if your time values are the order of magnitude shown they will
not meet the criteria above. Is the time value supposed to be seconds?
>
> Thanks,
> Janiv,.
--
Adrian Klaver
adrian(dot)klaver(at)gmail(dot)com
From | Date | Subject | |
---|---|---|---|
Next Message | Adam Witney | 2011-08-16 11:14:59 | which is better: using OR clauses or UNION? |
Previous Message | Janiv Ratson | 2011-08-16 09:15:58 | Re: bigint and unix time |