datediff ,datepart周

 

set datefirst 1
select DATEDIFF(wk,'2011-10-30 ','2011-11-1'),
DATEPART(ww, '2011-10-30'),
DATEPART(ww, '2011-11-1')


返回

0,44,45 

set datefirst 7
select DATEDIFF(wk,'2011-10-30 ','2011-11-1'),
DATEPART(ww, '2011-10-30'),
DATEPART(ww, '2011-11-1')

返回

0,45,45 

 

奇怪为啥datefirst设置了,对datepart有效但是对datediff就无效

 

你可能感兴趣的:(datediff)