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
No comments:
Post a Comment