set ANSI_NULLS ON set QUOTED_IDENTIFIER ON go ALTER FUNCTION [dbo].[ufn_getDateOfWeek] (@Date Datetime) RETURNS nchar(1) AS BEGIN DECLARE @returnValue nchar(1); SET @returnvalue = case datepart(dw,@Date) when 2 then ‘一‘ when 3 then ‘二‘ when 4 then ‘三‘ when 5 then ‘四‘ when 6 then ‘五‘ when 7 then ‘六‘ when 1 then ‘日‘ end; RETURN @returnValue END --------------------- set ANSI_NULLS ON set QUOTED_IDENTIFIER ON go ALTER FUNCTION [dbo].[ufn_TransDate] ( @Date DATETIME ) RETURNS nvarchar(50) AS /* Action: 讲时间传换成这样的格式 01-18 14:00 CreatedBy: CreatedDate: 2011-01-19 11:44:12.920 ModifiedHistory: Test Scripts: print dbo.ufn_TransDate(‘2011-01-19 11:44:12.920‘) */ BEGIN DECLARE @Str NVARCHAR(50) SET @Str = Convert(Nvarchar(19),Convert(DateTime,@Date,120),120) SET @Str = SUBSTRING(@Str,6,11) RETURN @Str END --------------------------------------- set ANSI_NULLS ON set QUOTED_IDENTIFIER ON go ALTER FUNCTION [dbo].[ufn_TransDate2] ( @Date DATETIME ) RETURNS nvarchar(50) AS /* Action: 讲时间传换成这样的格式 2011-01-18 CreatedBy: CreatedDate: 2011-01-19 11:44:12.920 ModifiedHistory: Test Scripts: print dbo.ufn_TransDate2(‘2011-01-19 11:44:12.920‘) */ BEGIN DECLARE @Str NVARCHAR(50) SET @Str = Convert(Nvarchar(19),Convert(DateTime,@Date,120),120) SET @Str = SUBSTRING(@Str,1,11) RETURN @Str END ----------------------------------------------