Tuesday, December 20, 2011

Creating procedure used for Diplaying current year of quater months data's should be Visible.



CREATE PROC [dbo].[THRSP_CurrentQuaterIdea]
AS
BEGIN
DECLARE @month INT;
SET @month=MONTH (GETDATE())
IF(@month =1 or @month=2 or @month =3)
BEGIN
SELECT *FROM Idea WHERE YEAR(CreatedOn)=YEAR(GETDATE()) and MONTH(CreatedOn) in (1,2,3)
END
ELSE IF(@month =4 or @month=5 or @month =6)
BEGIN
SELECT *FROM Idea WHERE YEAR(CreatedOn)=YEAR(GETDATE()) and MONTH(CreatedOn) in (4,5,6)
END
ELSE IF(@month =7 or @month=8 or @month =9)
BEGIN
SELECT *FROM Idea WHERE YEAR(CreatedOn)=YEAR(GETDATE()) and MONTH(CreatedOn) in (7,8,9)
END
ELSE IF(@month =10 or @month=11 or @month =12)
BEGIN
SELECT *FROM Idea WHERE YEAR(CreatedOn)=YEAR(GETDATE()) and MONTH(CreatedOn) in (10,11,12)
END

END


GO

No comments:

Post a Comment