[SQL] extracting from epoch values in pgsql

2009-09-19 Thread Gavin McCullagh
Hi folks, I have a db that I need to draw some stats from. The db itself is from the web application moodle which, perhaps to be cross-platform, uses unix epoch times stored as integers throughout (see table description at end of mail). I'd like to query some stats based on the appearance of obje

Re: [SQL] extracting from epoch values in pgsql

2009-09-19 Thread Kenneth Marshall
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; > >

Re: [SQL] extracting from epoch values in pgsql

2009-09-17 Thread Frank Bax
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 repl

Re: [SQL] extracting from epoch values in pgsql

2009-09-17 Thread Gavin McCullagh
On Thu, 17 Sep 2009, Osvaldo Kussama wrote: > 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)) Gah. I don't know I missed that. This works fine. SELECT extract(mo

Re: [SQL] extracting from epoch values in pgsql

2009-09-17 Thread Gavin McCullagh
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)

Re: [SQL] extracting from epoch values in pgsql

2009-09-17 Thread Osvaldo Kussama
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:  syntax error at or near "," >>> LINE 1: ...t time, to_timestamp(time) AS ts, extract('months'

Re: [SQL] extracting from epoch values in pgsql

2009-09-17 Thread 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: syntax error at or near "," >> LINE 1: ...t time, to_timestamp(time) AS ts, extract('months',to_times... > > Try replacing extr

Re: [SQL] extracting from epoch values in pgsql

2009-09-17 Thread Frank Bax
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

[SQL] extracting from epoch values in pgsql

2009-09-17 Thread Gavin McCullagh
Hi folks, I have a db that I need to draw some stats from. The db itself is from the web application moodle which, perhaps to be cross-platform, uses unix epoch times stored as integers throughout (see table description at end of mail). I'd like to query some stats based on the appearance of obje