sql - ORACLE find the first day and last day of a given quarter -


is there way can find first day , last day of given quarter?

if select first quarter should able first day , last day of first quarter

example:

quarter = 1 , year 2016. expected result 01/01/2016 - 31/03/2007 (dd/mm/yyyy format).

for example:

select(quarterdatestart, quarterdatedate) year = 2016 , quarter = 1; 

yes, can following:

first day of current year:

select trunc (sysdate , ‘year’) dual; 

last day of current year:

select add_months(trunc (sysdate, ’year’), 12) - 1 dual; 

by way, can use following find desired output:

with q(qtr) as(        select add_months( date '2016-01-01',       (level - 1) * 3 ) dual connect level <= 4 )        select qtr first_day,       last_day(add_months(qtr, 2)) last_day  q 

Comments