From: | Kenneth Marshall <ktm(at)rice(dot)edu> |
---|---|
To: | Gavin McCullagh <gavin(dot)mccullagh(at)gcd(dot)ie> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: extracting from epoch values in pgsql |
Date: | 2009-09-17 17:39:59 |
Message-ID: | 20090917173959.GE22802@it.is.rice.edu |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
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
From | Date | Subject | |
---|---|---|---|
Next Message | Craig Ringer | 2009-09-18 02:01:34 | Re: Hibernate, web application and only one sequence for all primary keys |
Previous Message | Frank Bax | 2009-09-17 17:38:34 | Re: extracting from epoch values in pgsql |