日期:2014-05-18  浏览次数:20467 次

如何求一个月的第一天是星期几
某个月的第一天是星期几在ms sqlserver里怎么求?

------解决方案--------------------
SQL code

--try

select datepart(weekday,'2007-09-01')

------解决方案--------------------
declare @year as varchar(4)
declare @month as varchar(2)
declare @day as varchar(2)
set @year = '2007'
set @month = '09'
set @day = '30'
--组合成date类型的变量
select cast(@year + '-' + @month + '-' + day as datetime) riqi
--判断当前月的第一天是星期几
select datepart(week,cast(convert(varchar(7),getdate(),120) + '01' as datetime)