pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Osvaldo Kussama <osvaldo.kussama@gmail.com>
To: Gavin McCullagh <gavin.mccullagh@gcd.ie>
Cc: Frank Bax <fbax@sympatico.ca>
Cc: pgsql-sql@postgresql.org
Subject: Re: extracting from epoch values in pgsql
Date: Thu, 17 Sep 2009 14:32:29 -0300
Message-ID: <690707f60909171032q4ba19ef8y30e31c7f7ca0a0b0@mail.gmail.com> (raw)
In-Reply-To: <20090917173039.GV16815@gcd.ie>
References: <20090917164439.GU16815@gcd.ie>
	<4AB26B6F.4010207@sympatico.ca>
	<20090917173039.GV16815@gcd.ie>

2009/9/17 Gavin McCullagh <gavin.mccullagh@gcd.ie>:
> 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...
>                                                             ^


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



view thread (9+ messages)  latest in thread

Message-ID: <690707f60909171032q4ba19ef8y30e31c7f7ca0a0b0@mail.gmail.com>
Permalink:  ../690707f60909171032q4ba19ef8y30e31c7f7ca0a0b0@mail.gmail.com/
Also on:    postgresql.org/message-id/690707f60909171032q4ba19ef8y30e31c7f7ca0a0b0@mail.gmail.com

 · 

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: osvaldo.kussama@gmail.com, gavin.mccullagh@gcd.ie, fbax@sympatico.ca
  Subject: Re: extracting from epoch values in pgsql
  In-Reply-To: <690707f60909171032q4ba19ef8y30e31c7f7ca0a0b0@mail.gmail.com>

* 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