Last active
December 14, 2015 00:48
-
-
Save tsnoad/5001308 to your computer and use it in GitHub Desktop.
get financial year from a date in oracle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with dates as ( | |
select sysdate-240 as sometime from dual | |
union select sysdate-180 as sometime from dual | |
union select sysdate-120 as sometime from dual | |
union select sysdate-60 as sometime from dual | |
union select sysdate as sometime from dual | |
union select sysdate+60 as sometime from dual | |
union select sysdate+120 as sometime from dual | |
union select sysdate+180 as sometime from dual | |
union select sysdate+240 as sometime from dual | |
union select to_date('2013-06-30', 'YYYY-MM-DD') as sometime from dual | |
union select to_date('2013-07-01', 'YYYY-MM-DD') as sometime from dual | |
) | |
select | |
sometime, | |
'FY'||to_char( | |
extract(year from sometime) | |
+floor((extract(month from sometime)-1)/6) | |
) as financial_year | |
from dates |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment