Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 financial year query

Author  Topic 

Davin21
Starting Member

3 Posts

Posted - 2010-08-04 : 07:39:14
Hi all,
I'm looking to be able to pull out information about people who have bought something during the last 5 financial years (a rolling 5 year period that would update when the current year changes)

I want to be able to fix the following parts of the date ranges:
Financial month / day start 4th April
Financial month / day end 31st March

But to have the year defined by a parameter something like this:
Financial year start = YEAR(DATEADD(YY,-1,(GETDATE()))
Financial year end = YEAR(GETDATE())

For the current year, and then repeat this for the most recent financial year, the 2nd most recent financial year etc...

Ideally I would like to get following output:
Current Year | financial year | bought? | financial year-1 | bought
2010 2009-2010 Yes 2008-2009 No

I am unable to create functions in the database, and so something inbuilt into the query would be useful!

Apologies if this is covered elsewhere but I can't use the search function for some reason!
TIA :)

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-08-09 : 04:52:17
Which version of SQL Server are you using?
Read about PIVOT operator in SQL Server help file

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -