Search Postgresql Archives

generate_series with month intervals

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi list,

I'd like to generate the latest year dynamically with generate_series.
This select works day wise:

select date_trunc ('month', now())::date + s.a
from generate_series(0, 11) as s(a)

I tried this but it didn't work:

select date_trunc ('month', now())::date + interval s.a || ' months'
from generate_series(0, 11) as s(a)

This works but looks grotesque:

select distinct date_trunc ('month', now()::date + s.a)::date
from generate_series(0, 365) as s(a)

Is there a way to do this more elegantly?

Best regards,
Marcus



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux