Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- https://pgexercises.com/questions/date/daysinmonth.html
- -- date_part does not work for the second column of the second clause, but date_trunc does
- with gs as (select generate_series(
- '2012-01-01'::timestamp,
- '2012-12-31'::timestamp,
- '1 month'::interval) as month)
- select date_part('month', month) as m,
- (date_trunc('month', month)+'1 month'::INTERVAL)-date_trunc('month', month) as len
- from gs
Advertisement
Add Comment
Please, Sign In to add comment