Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id EE1636336A4 for ; Thu, 17 Sep 2009 14:30:52 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 58654-10 for ; Thu, 17 Sep 2009 17:30:40 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from gcd.ie (mail1.gcd.ie [83.141.104.148]) by mail.postgresql.org (Postfix) with ESMTP id F3BC963363A for ; Thu, 17 Sep 2009 14:30:41 -0300 (ADT) Received: from localhost (localhost [127.0.0.1]) by gcd.ie (Postfix) with ESMTP id 53D4A26A001B; Thu, 17 Sep 2009 18:30:40 +0100 (BST) Received: from gcd.ie ([127.0.0.1]) by localhost (dubmail.gcd.ie [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 19510-05; Thu, 17 Sep 2009 18:30:40 +0100 (BST) Received: from ceartgoleor (unknown [172.16.1.3]) by gcd.ie (Postfix) with ESMTP id 174F726A0007; Thu, 17 Sep 2009 18:30:40 +0100 (BST) Received: by ceartgoleor (Postfix, from userid 1000) id 0E3E65100AB; Thu, 17 Sep 2009 18:30:40 +0100 (IST) Date: Thu, 17 Sep 2009 18:30:40 +0100 From: Gavin McCullagh To: Frank Bax Cc: pgsql-sql@postgresql.org Subject: Re: extracting from epoch values in pgsql Message-ID: <20090917173039.GV16815@gcd.ie> Reply-To: Gavin McCullagh References: <20090917164439.GU16815@gcd.ie> <4AB26B6F.4010207@sympatico.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4AB26B6F.4010207@sympatico.ca> User-Agent: Mutt/1.5.18 (2008-05-17) X-Virus-Scanned: by amavisd-new at gcd.ie X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.855 tagged_above=-10 required=5 tests=AWL=-0.745, BAYES_05=-1.11 X-Spam-Level: X-Archive-Number: 200909/84 X-Sequence-Number: 33149 On Thu, 17 Sep 2009, Frank Bax wrote: > Gavin McCullagh wrote: >> SELECT time, to_timestamp(time) AS ts, >> EXTRACT('months',to_timestamp(time)) FROM mdl_log; >> ERROR: syntax error at or near "," >> LINE 1: ...t time, to_timestamp(time) AS ts, extract('months',to_times... > > Try replacing extract('month',value) with extract('months' from value) Makes no difference whether month or months: moodle-01-01-2009=# select time, to_timestamp(time) AS ts, extract('month','to_timestamp(time)') from mdl_log LIMIT 10; ERROR: syntax error at or near "," LINE 1: ...ct time, to_timestamp(time) AS ts, extract('month','to_times... ^ moodle-01-01-2009=# select time, to_timestamp(time) AS ts, extract('months','to_timestamp(time)') from mdl_log LIMIT 10; ERROR: syntax error at or near "," LINE 1: ...t time, to_timestamp(time) AS ts, extract('months','to_times... ^ Gavin