USE [DB]
GO
/****** Object: UserDefinedFunction [dbo].[udf_Fiscal_Year] ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Description: <Description,,>
-- =============================================
ALTER FUNCTION [dbo].[udf_Fiscal_Year] (@datetime datetime)
RETURNS varchar(50)
AS
begin
declare @FY varchar(50)
select @FY=(CASE WHEN Month(@datetime) IN (5,6,7,8,9,10,11,12) THEN Year(Dateadd(yy,1,@datetime)) ELSE Year(@datetime) END)
return @FY
end
Tuesday, August 13, 2013
Stored Procedures - Quarter
USE [DB]
GO
/****** Object: UserDefinedFunction [dbo].[udf_Quarter] ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER FUNCTION [dbo].[udf_Quarter] (@datetime datetime)
RETURNS varchar(50)
AS
begin
declare @bill varchar(50)
select @bill=( CASE WHEN Month(@datetime) IN ( 5, 6, 7 ) THEN 'Q1' WHEN Month(@datetime) IN ( 8, 9, 10 ) THEN 'Q2' WHEN Month(@datetime) IN ( 11, 12, 1 ) THEN 'Q3' WHEN Month(@datetime) IN ( 2, 3, 4 ) THEN 'Q4' ELSE NULL END )
return @bill
end
GO
/****** Object: UserDefinedFunction [dbo].[udf_Quarter] ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER FUNCTION [dbo].[udf_Quarter] (@datetime datetime)
RETURNS varchar(50)
AS
begin
declare @bill varchar(50)
select @bill=( CASE WHEN Month(@datetime) IN ( 5, 6, 7 ) THEN 'Q1' WHEN Month(@datetime) IN ( 8, 9, 10 ) THEN 'Q2' WHEN Month(@datetime) IN ( 11, 12, 1 ) THEN 'Q3' WHEN Month(@datetime) IN ( 2, 3, 4 ) THEN 'Q4' ELSE NULL END )
return @bill
end
Subscribe to:
Comments (Atom)