I want to select sql:
SELECT "year-month" from table group by "year-month" AND order by date
, where
year-month – format for date “1978-01″,”1923-12”.
select to_char of couse work, but not “right” order:
to_char(timestamp_column, 'YYYY-MM')
Advertisement
Answer
date_part(text, timestamp)
e.g.
date_part('month', timestamp '2001-02-16 20:38:40'), date_part('year', timestamp '2001-02-16 20:38:40')
http://www.postgresql.org/docs/8.0/interactive/functions-datetime.html