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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 fiscal year. original i know

Author  Topic 

kbromwich
Starting Member

5 Posts

Posted - 2008-10-03 : 02:15:38
i need a sql statement that i can supply a date range and it will calculate all the fiscal years within that date range.
the fiscal year for this will be 1 jul - 30 Jun following year.

example
user asks for data from 2000 to 2008
data returned would be
00/01 calculated data
01/02 calculated data
02/03 calculated data
etc

i was hoping to do this in one sql statement. i was playing with a case statement but that does not seem to be working.

cheers

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-10-03 : 02:31:42
[code]SELECT YEAR(DATEADD(mm,DATEDIFF(mm,0,datefield)+5,0)),
calaculations
FROM YourTable
GROUP BY YEAR(DATEADD(mm,DATEDIFF(mm,0,datefield)+5,0))[/code]
Go to Top of Page
   

- Advertisement -