Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 29D42B5DBD0 for ; Sun, 14 Aug 2011 14:57:17 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 67386-09 for ; Sun, 14 Aug 2011 17:57:11 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-iy0-f172.google.com (mail-iy0-f172.google.com [209.85.210.172]) by mail.postgresql.org (Postfix) with ESMTP id D9E87B5DBBF for ; Sun, 14 Aug 2011 14:57:10 -0300 (ADT) Received: by iye7 with SMTP id 7so11885447iye.17 for ; Sun, 14 Aug 2011 10:57:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:subject:date:user-agent:cc:references:in-reply-to :mime-version:content-type:content-transfer-encoding:message-id; bh=7gb4oofhFavMa2rJ2WpIrWnkOK/W0RwQh9Zhb4FRmBQ=; b=tMb4UQyhlSuvxf6aOqnnqVNz+0TmCuwz5CpGx0qDh0AGkr7LOKoRbl6peEoXcgN06F XnMWZrv4IkKHlxycr2r1x/1BuQ4No0mkY+YugA2rSvtGZmZk6hGfpjDwcFL2G375UQwC zpuF5hOS0rcjkz8C9UNsXvaqG3fbH2nlw+fhw= Received: by 10.42.130.199 with SMTP id w7mr3184144ics.470.1313344629834; Sun, 14 Aug 2011 10:57:09 -0700 (PDT) Received: from tucker.localnet (c-24-17-164-54.hsd1.wa.comcast.net [24.17.164.54]) by mx.google.com with ESMTPS id e8sm3331248ibd.37.2011.08.14.10.57.08 (version=SSLv3 cipher=OTHER); Sun, 14 Aug 2011 10:57:08 -0700 (PDT) From: Adrian Klaver To: pgsql-sql@postgresql.org Subject: Re: bigint and unix time Date: Sun, 14 Aug 2011 10:57:05 -0700 User-Agent: KMail/1.13.5 (Linux/2.6.32-33-generic; KDE/4.4.5; i686; ; ) Cc: "Janiv Ratson" References: <9C103394ED80654B9DD6D9347E9D3001040F2014@es-ex1-il.essencesecurity.com> In-Reply-To: <9C103394ED80654B9DD6D9347E9D3001040F2014@es-ex1-il.essencesecurity.com> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Message-Id: <201108141057.05589.adrian.klaver@gmail.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.889 tagged_above=-5 required=5 tests=BAYES_00=-1.9, FREEMAIL_FROM=0.001, T_TO_NO_BRKTS_FREEMAIL=0.01 X-Spam-Level: X-Archive-Number: 201108/41 X-Sequence-Number: 35709 On Sunday, August 14, 2011 4:13:30 am Janiv Ratson wrote: > Hi, > > > > I have the following query: > > > > select ticket as ticket, time as created, author as reporter, > cast(extract(epoch from (date 'now' - integer '30')) as bigint) > > from ticket_change tc > > where field = 'status' > > and newvalue = 'reopened' > > and time > extract(epoch from (date 'now' - integer '30')) > > order by time > > > > I'm trying it get all records that their 'time' is within the past 30 > days. > > However, the time is bigint: 1287323899000000 > > While the extract(epoch from (date 'now' - integer '30')) is 1310677200 Bigint versus integer refers to the max values that the field can contain. For a given value of integer the storage should be the same for each up to the limit of the integer field. Would seem that whatever is putting values into time is inflating the values if they are actually referring to contemporary time values. > > > > As you understand, I always get all records ... > > > > How do I solve it? > > > > Thanks, > > Janiv. > -- Adrian Klaver adrian.klaver@gmail.com