我希望有这样的日期格式
Monday, the Thirty-First of July, 2000.
我尝试使用该模式,但我没有在文本中获取日期。
我只能获得31 july, 2000
。
提前谢谢
答案 0 :(得分:3)
CREATE FUNCTION fn_DateString
(
-- input parameter
@date datetime2
)
RETURNS varchar(100)
AS
BEGIN
DECLARE @Result varchar(100)
DECLARE @day as varchar(50)
set @day =
case DATEPART(day, @date)
when 1 then 'First'
when 2 then 'Second'
when 31 then 'Thirty-First'
else '<add other>'
end
SELECT @result = cast(DATENAME(dw,@date) as varchar) +
', the ' +
CAST(@day as varchar) +
' of ' +
CAST(DATENAME(MONTH, @date) as varchar) +
', ' +
CAST(YEAR(@date) as varchar)
RETURN @Result
END
GO