Posts

Showing posts from May, 2017

Display Fiscal Year, Quarter and week in the quarter

At times we want to see what year, quarter or week in the quarter today or another date is. The below query follows Oracle's fiscal year but should be easily modifiable to other fiscal years. select 'FY' || substr (( case when extract ( month from sysdate ) > 5 then extract ( year from sysdate ) +1 else extract ( year from sysdate ) end ), 3 , 2 ) || 'Q' || ( case when extract ( month from sysdate ) between 1 and 2 then '3 Week ' || to_char ( floor (( sysdate - to_date ( to_char ( extract ( year from sysdate ) -1 )|| '-12-01' , 'YYYY-MM-DD' ))/ 7 ) +1 ) when extract ( month from sysdate ) between 3 and 5 then '4 Week ' || to_char ( floor (( sysdate - to_date ( to_char ( extract ( year from sysdate ))|| '-03-01' , 'YYYY-MM-DD' ))/ 7 ) +1 ) when extract ( month from sysdate ) between 6 and 8 then '1 Week ' |...

First entry

My first attempt at blogging. This will primarily be used as an archive for myself and code snippets I develop but in case someone night be helped by something I do then great!