pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Kenneth Marshall <ktm@rice.edu>
To: Gavin McCullagh <gavin.mccullagh@gcd.ie>
Cc: pgsql-sql@postgresql.org
Subject: Re: extracting from epoch values in pgsql
Date: Thu, 17 Sep 2009 12:39:59 -0500
Message-ID: <20090917173959.GE22802@it.is.rice.edu> (raw)
In-Reply-To: <20090917173439.GW16815@gcd.ie>
References: <20090917164439.GU16815@gcd.ie>
	<4AB26B6F.4010207@sympatico.ca>
	<20090917173039.GV16815@gcd.ie>
	<20090917173439.GW16815@gcd.ie>

On Thu, Sep 17, 2009 at 06:34:39PM +0100, Gavin McCullagh wrote:
> On Thu, 17 Sep 2009, Gavin McCullagh wrote:
> 
> > 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:
> 
> Actually, I pasted a different query, but based on the one in my last
> email:
> 
> moodle-01-01-2009=# SELECT EXTRACT('months',(TIMESTAMP WITH TIME ZONE 'epoch' + mdl_log.time * INTERVAL '1 second'))
> FROM mdl_log;
> ERROR:  syntax error at or near ","
> LINE 1: SELECT EXTRACT('months',(TIMESTAMP WITH TIME ZONE 'epoch' + ...
>                                ^
> moodle-01-01-2009=# SELECT EXTRACT('month',(TIMESTAMP WITH TIME ZONE 'epoch' + mdl_log.time * INTERVAL '1 second'))
> FROM mdl_log;
> ERROR:  syntax error at or near ","
> LINE 1: SELECT EXTRACT('month',(TIMESTAMP WITH TIME ZONE 'epoch' + m...
>                               ^
> 
> Gavin
> 
Gavin,

I think Frank had the answer:

Try replacing extract('month',value) with extract('months' from value)

Look at the documentation for the syntax for further details.

Regards,
Ken



view thread (9+ messages)

Message-ID: <20090917173959.GE22802@it.is.rice.edu>
Permalink:  ../20090917173959.GE22802@it.is.rice.edu/
Also on:    postgresql.org/message-id/20090917173959.GE22802@it.is.rice.edu

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: ktm@rice.edu, gavin.mccullagh@gcd.ie
  Subject: Re: extracting from epoch values in pgsql
  In-Reply-To: <20090917173959.GE22802@it.is.rice.edu>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox