-- 取季初那一天
select date_trunc( 'quarter',cast('20150820' as date))
-- 取季末那一天
select add_months(date_trunc( 'quarter',cast('20150820' as date)) + INTERVAL '-1 day',3)

-- 取上季末那一天
select date_trunc( 'quarter',cast('20150820' as date)) + INTERVAL '-1 day'
-- 取上季初那一天
select add_months(date_trunc( 'quarter',cast('20150820' as date)),-3)