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
 Analysis Server and Reporting Services (2005)
 custom dimension in ssas cube

Author  Topic 

phanicrn
Starting Member

42 Posts

Posted - 2011-01-13 : 16:43:54
How do i write calculation for 12 month period starting which is February of every year to January of next year.
i have time table which has three years of data by year, quarter, month..
How can i achieve this in a calculated column..
12 month period
2008 feb, march, apr, may, jun, jul, aug, sep, oct, nov,dec, 2009 jan.

Thanks
Sid

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-01-16 : 06:17:53
may be this?

SELECT YEAR(date),DATENAME(mm,date)
FROM table
WHERE datefield >= DATEADD(mm,1,DATEADD(yy,@year-1900,0))
AND datefield < DATEADD(mm,1,DATEADD(yy,@year-1899,0))
GROUP BY YEAR(date),MONTH(date),DATENAME(mm,date)
ORDER BY YEAR(date),MONTH(date)


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -