sql server - SQL to separate YYYY MM to fiscal year -


i have column states month , year yyyy mm. i've separated 2 columns (year , month). problem is, year calendar year whereas ideally need fiscal year use (apr 01 mar 31 - never change).

other solutions i've seen based on date format, whereas original column string.

i need statement returns fiscal year new year column instead of calendar year.

my current statement is:

select month, parsename(replace(month,' ','.'),1) monthm, parsename(replace(month,' ','.'),2) year tbltrade 

which works separate columns.

so expected results example: feb 15 becomes feb , 2015. apr 15 becomes apr , 2016.

please advise.

sql server:

declare @date datetime = getdate(); select  (year(dateadd(month,-((datepart(month,@date)+5) %12),@date))) financial_year 

assuming april month 1


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -