Extract week from date

From: Dani Castaños <dcastanos(at)androme(dot)es>
To: <pgsql-sql(at)postgresql(dot)org>
Subject: Extract week from date
Date: 2009-05-18 14:41:09
Message-ID: 007d01c9d7c6$af6aac70$0e400550$@es
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi again,

I need to extract date grouped by week from an statistics table.

I was trying something like this:

SELECT total_duration, EXTRACT( week from date statistics_date )
FROM statistics_daily
GROUP BY EXTRACT( week from date statistics_date ), total_duration;

But it doesn't works... Neither:

SELECT total_duration, statistics_date
FROM statistics_daily
GROUP BY EXTRACT( day from statistics_date ), total_duration,
statistics_date;

How can it be done?

Note: statistics_date is a DATE data type column.

Regards.

--
Dani Castaños Sánchez
dcastanos(at)androme(dot)es

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Filip Rembiałkowski 2009-05-18 14:54:12 Re: Extract week from date
Previous Message Pawel Socha 2009-05-18 13:31:57 Re: SUM Array values query