Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

Fiscal/Financial Year Comparison SQL

Avatar of Ross Turner
Ross TurnerFlag for United Kingdom of Great Britain and Northern Ireland asked on
Microsoft SQL ServerMicrosoft SQL Server 2008SQL
4 Comments1 Solution1205 ViewsLast Modified:
Hi EE,
I’m trying to create a stored procedure that will get the total value for the Financial Year to Date by customer, but then I want to show the previous Financial Year to Date as well for comparison.
So take today (July 9th 2012) I want to get all the values from (May  1st 2012 to July 9th 2012) for Current Financial Year .
So last year would run from (May  1st 2011 to July 9th 2011) to make an accurate comparison.

Our Financial Years always run from (May 1st to the following April 30th)

Below is a mock up picture of what i'm trying to achieve.

i seem to be going round in circles....

FY Comparison
ECLARE @CurrentFinancialYear	as Int
DECLARE @LastFinancialYear		as Int
SET		@CurrentFinancialYear	='2012'
SET		@LastFinancialYear		='2011'

Select				invoicedate												As [FullDate],
					customer.name											As [CustomerName],	
					InvoiceHead.fiscalyear									AS [FinancialYear],
					InvoiceHead.fiscalperiod								AS [FinancialYear],
					DATENAME(MONTH,InvoiceHead.invoicedate)					AS [FinancialMonthName],
					(dbo.invcdtl.sellingshipqty * dbo.invcdtl.unitprice)	AS [Value]
from				  dbo.invchead as InvoiceHead 
                      dbo.invcdtl ON InvoiceHead.invoicenum = dbo.invcdtl.invoicenum
        INNER JOIN
                      dbo.customer ON InvoiceHead.custnum = dbo.customer.custnum

where	InvoiceHead.fiscalyear = @CurrentFinancialYear 
order by fulldate

Thank you for your Help....

Avatar of Lowfatspread
This problem has been solved!
Unlock 1 Answer and 4 Comments.
See Answers