Wednesday, March 10, 2010

Find quarter date with sql query

select add_months(to_date(to_char('0101'||to_char(:P_Date,'YYYY')),'ddmmyyyy'),to_char(:P_Date,'Q')*3)-1
from dual


select add_months(to_date(to_char('0101'||to_char(:P_Date,'YYYY')),'ddmmyyyy'),to_char(:P_Date,'Q')*3)-1
from(select sysdate from dba_objects
where rownum<=4)

select add_months(last_day(:ysdate),to_char(:ysdate,'Q')*3) as year_quarter
from dual;

1 comment:

簡單 said...

失意人前,勿談得意事;得意人前,勿談失意事。........................................