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 Comments2 Solutions1205 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 
		INNER JOIN
                      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....

Ross
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 2 Answers and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros