:第幾周函式相信我都知道資料庫已經自帶 (經實測考勤工資計算利用,非實用我網路苦苦尋找原始碼找關於vb程式碼我想資料庫實現做處能提高資料讀取速度統計析帶處實沒板催急自便段vb程式碼轉化SQL語句問題敬請提萬我公司考勤工資計算搞問題完其實段程式碼拼函式資料庫非簡單實用) CREATE FUNCTION WeekOfMonth(@day datetime) RETURNS intASbegin----declare @day datetime declare @num int declare @Start datetime declare @dd int declare @dayofweek char(8) declare @dayofweek_num char(8) declare @startWeekDays int if datepart(dd,@day)=1return 1elseset @Start= (SELECT DATEADD(mm, DATEDIFF(mm,0,@day), 0)) --月第 set @dayofweek= (datename(weekday,@Start)) ---本月第周幾 set @dayofweek_num=(select (case @dayofweek when "星期" then 2 when "星期二" then 3 when "星期三" then 4 when "星期四" then 5 when "星期五" then 6 when "星期六" then 7 when "星期" then 1end))set @dayofweek_num= 7-@dayofweek_num+1 ---本月第周共幾 ---print @dayofweek_num set @dd=datepart(dd,@day) ----今月第幾 --print @ddif @dd<=@dayofweek_num --於前週數return 1elseset @dd=@dd-@dayofweek_num if @dd % 7=0beginset @num=@dd / 7 return @num+1endelse --if @dd % 7<0set @num=@dd / 7
:第幾周函式相信我都知道資料庫已經自帶 (經實測考勤工資計算利用,非實用我網路苦苦尋找原始碼找關於vb程式碼我想資料庫實現做處能提高資料讀取速度統計析帶處實沒板催急自便段vb程式碼轉化SQL語句問題敬請提萬我公司考勤工資計算搞問題完其實段程式碼拼函式資料庫非簡單實用) CREATE FUNCTION WeekOfMonth(@day datetime) RETURNS intASbegin----declare @day datetime declare @num int declare @Start datetime declare @dd int declare @dayofweek char(8) declare @dayofweek_num char(8) declare @startWeekDays int if datepart(dd,@day)=1return 1elseset @Start= (SELECT DATEADD(mm, DATEDIFF(mm,0,@day), 0)) --月第 set @dayofweek= (datename(weekday,@Start)) ---本月第周幾 set @dayofweek_num=(select (case @dayofweek when "星期" then 2 when "星期二" then 3 when "星期三" then 4 when "星期四" then 5 when "星期五" then 6 when "星期六" then 7 when "星期" then 1end))set @dayofweek_num= 7-@dayofweek_num+1 ---本月第周共幾 ---print @dayofweek_num set @dd=datepart(dd,@day) ----今月第幾 --print @ddif @dd<=@dayofweek_num --於前週數return 1elseset @dd=@dd-@dayofweek_num if @dd % 7=0beginset @num=@dd / 7 return @num+1endelse --if @dd % 7<0set @num=@dd / 7