Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 512D663363A for ; Thu, 17 Sep 2009 14:32:42 -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 58948-09 for ; Thu, 17 Sep 2009 17:32:29 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-fx0-f210.google.com (mail-fx0-f210.google.com [209.85.220.210]) by mail.postgresql.org (Postfix) with ESMTP id 4D3FA632CD2 for ; Thu, 17 Sep 2009 14:32:31 -0300 (ADT) Received: by fxm6 with SMTP id 6so198704fxm.19 for ; Thu, 17 Sep 2009 10:32:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=oWRxPWK86EJyqnrYFaUy5oljgXaE01WOlUZL7eu8YH8=; b=YR8jUhOXwLwZ5TVl5A07wfVe2AlNPbJD9FPjqsn6zuG3H8wTWa6nayna7qAg0X5hNF 0Yo91hj0aXd0SI/fhpWWI/OnNNysOwVxOyMd99wwrqKAN1CeJbyePvWOgOJlzstCpMsy HL/TxJe6FDypobOc7EcqgukU4R+UceZFPUqYA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=uAbk7UZ8Y0PX0R+yBxE76pfoO3RWrF0nHOArb8VuFbhX5NAhtV/Bh67luv5EhSM4iB hFDpBNuJtXo/CkHNPbNgtxmgX3yR9bql5RObQVTRs98Z0Jz8mSsMKX/0r37L6Bjq44lS UB5h8Pa/4wk3pxmJf47TKmNRv4Xl3o/OLt5cY= MIME-Version: 1.0 Received: by 10.239.145.18 with SMTP id q18mr29758hba.120.1253208749385; Thu, 17 Sep 2009 10:32:29 -0700 (PDT) In-Reply-To: <20090917173039.GV16815@gcd.ie> References: <20090917164439.GU16815@gcd.ie> <4AB26B6F.4010207@sympatico.ca> <20090917173039.GV16815@gcd.ie> Date: Thu, 17 Sep 2009 14:32:29 -0300 Message-ID: <690707f60909171032q4ba19ef8y30e31c7f7ca0a0b0@mail.gmail.com> Subject: Re: extracting from epoch values in pgsql From: Osvaldo Kussama To: Gavin McCullagh Cc: Frank Bax , pgsql-sql@postgresql.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.599 tagged_above=-10 required=5 tests=BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 200909/85 X-Sequence-Number: 33150 2009/9/17 Gavin McCullagh : > 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: =A0syntax 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=3D# select time, to_timestamp(time) AS ts, extract('mon= th','to_timestamp(time)') from mdl_log LIMIT 10; > ERROR: =A0syntax error at or near "," > LINE 1: ...ct time, to_timestamp(time) AS ts, extract('month','to_times..= . > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ^ > moodle-01-01-2009=3D# select time, to_timestamp(time) AS ts, extract('mon= ths','to_timestamp(time)') from mdl_log LIMIT 10; > ERROR: =A0syntax error at or near "," > LINE 1: ...t time, to_timestamp(time) AS ts, extract('months','to_times..= . > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ^ From manual: http://www.postgresql.org/docs/current/interactive/functions-datetime.html date_part('month',to_timestamp(time)) or extract(month from to_timestamp(time)) Osvaldo