• 通过月份得到本月有几天周末


    CREATE FUNCTION getweekdayCount ( @month varchar(10))
    RETURNS INT
    AS
    BEGIN
    --declare @month varchar(10)
    --set @month='201802'
    ---通过月份得到本月有几天周末
    DECLARE @DAYCOUNT int
    DECLARE @datestart datetime
    DECLARE @dateend datetime

    set @datestart =cast(SUBSTRING( @month,0,5)+'-'+SUBSTRING( @month,5,2)+'-01' as datetime)
    set @dateend=dateadd(ms,-3,DATEADD(mm, DATEDIFF(m,0,@datestart)+1, 0))
    SET @DAYCOUNT=0
    while @datestart<=@dateend
    begin

    if(datename(weekday,@datestart)= '星期日' or datename(weekday,@datestart)='星期六') begin
    set @DAYCOUNT=@DAYCOUNT+1
    end
    SET @DATESTART=DATEADD(DAY,1,@DATESTART)

    end

    RETURN(@DAYCOUNT)
    END

  • 相关阅读:
    yii中通过HTTP post接收
    网络编程
    python 异常处理
    面向对象(2)
    面向对象
    什么是模块精讲
    常用模块二
    各种推导式详解
    匿名函数
    迭代器生成器
  • 原文地址:https://www.cnblogs.com/cuozhixu/p/8854824.html
Copyright © 2020-2023  润新知