- /****** Object: UserDefinedFunction [dbo].[dayInWeek] Script Date: 2016/1/19 11:21:54 ******/
- SET ANSI_NULLS ON
- GO
- SET QUOTED_IDENTIFIER ON
- GO
- CREATE function [dbo].[dayInWeek]( @year int,@month int,@day int)
- returns int
- as
- begin
- declare @ofweek int
- set @ofweek =0
- if ( @month<3 )
- begin
- set @month = 12 + @month
- set @year = @year -1
- end
- set @ofweek = (@day+2*@month+3*(@month+1)/5+@year+@year/4-@year/100+@year/400)%7
- return @ofweek
- end
- GO
- --该片段来自于http://www.codesnippet.cn/detail/1901201614460.html
来源: http://www.codesnippet.cn/detail/1901201614460.html