I have already built a holidays table containing all public holidays from 2000 to 2050. But I have should have put also all weekend dates and now I am trying to find an approach to it. Ca开发者_如何转开发n somebody suggest something? I checked and there are functions for calculating the number of the business days, but I need insertion of all weekends between these two years.
If 8.4+:
select
a::date as Sunday,
a::date - 1 as Saturday
from generate_series('2000-01-02'::date, '2050-12-31', '7 days') s(a)
;
Else:
select
'2000-01-02'::date + s.a as Sunday,
'2000-01-02'::date + s.a - 1 as Saturday
from generate_series(0, '2050-12-31'::date - '2000-01-02'::date, 7) s(a)
;
精彩评论