Generate series of week intervals for given month
问题 In a Postgres 9.1 database, I am trying to generate a series of weeks for a given month but with some constraints. I need all weeks to start on Monday and get cut when they start or end in another month. Example: For February, 2013 I want to generate a series like this: start ------------------------ 2013-02-01 00:00:00+00 2013-02-04 00:00:00+00 2013-02-11 00:00:00+00 2013-02-18 00:00:00+00 2013-02-25 00:00:00+00 The query that I have now looks like this: SELECT GREATEST(date_trunc('week',