[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-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 n

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,

[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