Re: bigint and unix time

Поиск
Список
Период
Сортировка
От Adrian Klaver
Тема Re: bigint and unix time
Дата
Msg-id 201108150714.08500.adrian.klaver@gmail.com
обсуждение исходный текст
Ответ на bigint and unix time  ("Janiv Ratson" <janivra@essence-grp.com>)
Ответы Re: bigint and unix time  (Janiv Ratson <yanivra@essence-grp.com>)
Re: bigint and unix time  (Janiv Ratson <yanivra@essence-grp.com>)
Re: bigint and unix time  (Janiv Ratson <yanivra@essence-grp.com>)
Список pgsql-sql
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')) 
ANDextract(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.klaver@gmail.com


В списке pgsql-sql по дате отправления:

Предыдущее
От: Andreas Forø Tollefsen
Дата:
Сообщение: Re: Calculate the ratio
Следующее
От: Janiv Ratson
Дата:
Сообщение: Re: bigint and unix time