Re: extracting from epoch values in pgsql

From: Osvaldo Kussama <osvaldo(dot)kussama(at)gmail(dot)com>
To: Gavin McCullagh <gavin(dot)mccullagh(at)gcd(dot)ie>
Cc: Frank Bax <fbax(at)sympatico(dot)ca>, pgsql-sql(at)postgresql(dot)org
Subject: Re: extracting from epoch values in pgsql
Date: 2009-09-17 17:32:29
Message-ID: 690707f60909171032q4ba19ef8y30e31c7f7ca0a0b0@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-sql

2009/9/17 Gavin McCullagh <gavin(dot)mccullagh(at)gcd(dot)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

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Gavin McCullagh 2009-09-17 17:34:39 Re: extracting from epoch values in pgsql
Previous Message Gavin McCullagh 2009-09-17 17:30:40 Re: extracting from epoch values in pgsql