udf_WeekDayName
复制代码 代码如下:
CREATE FUNCTION [dbo].[udf_WeekDayName]
(
)
RETURNS @WeekDayName TABLE([Id] INT,[WeekDayName] NVARCHAR(15))
AS
BEGIN
INSERT INTO @WeekDayName ([Id],[WeekDayName]) VALUES (0,'Saturday'),(1,'Sunday'),(2,'Monday'),(3,'Tuesday'),(4,'Wednesday'),(5,'Thursday'),(6,'Friday')
RETURN
END
udf_WeekDayNameOfDate
复制代码 代码如下:
CREATE FUNCTION [dbo].[udf_WeekDayNameOfDate]
(
@Date DATETIME
)
RETURNS NVARCHAR(10)
BEGIN
RETURN
CASE (DATEPART(dw, @Date) + @@DATEFIRST) % 7
WHEN 0 THEN 'Saturday'
WHEN 1 THEN 'Sunday'
WHEN 2 THEN 'Monday'
WHEN 3 THEN 'Tuesday'
WHEN 4 THEN 'Wednesday'
WHEN 5 THEN 'Thursday'
WHEN 6 THEN 'Friday'
END
END
复制代码 代码如下:
CREATE FUNCTION [dbo].[udf_WeekDayName]
(
)
RETURNS @WeekDayName TABLE([Id] INT,[WeekDayName] NVARCHAR(15))
AS
BEGIN
INSERT INTO @WeekDayName ([Id],[WeekDayName]) VALUES (0,'Saturday'),(1,'Sunday'),(2,'Monday'),(3,'Tuesday'),(4,'Wednesday'),(5,'Thursday'),(6,'Friday')
RETURN
END
udf_WeekDayNameOfDate
复制代码 代码如下:
CREATE FUNCTION [dbo].[udf_WeekDayNameOfDate]
(
@Date DATETIME
)
RETURNS NVARCHAR(10)
BEGIN
RETURN
CASE (DATEPART(dw, @Date) + @@DATEFIRST) % 7
WHEN 0 THEN 'Saturday'
WHEN 1 THEN 'Sunday'
WHEN 2 THEN 'Monday'
WHEN 3 THEN 'Tuesday'
WHEN 4 THEN 'Wednesday'
WHEN 5 THEN 'Thursday'
WHEN 6 THEN 'Friday'
END
END
版权声明
本文仅代表作者观点,不代表本站立场。
本文系作者授权发表,未经许可,不得转载。
本文地址:/shujuku/MsSQL/99506.html