离我回家还有多久(SQL版)
SELECT IDENTITY(int, 1,1) AS ID_Num into #t FROM sysobjects
SELECT
COUNT(*) AS 天数,SUM(CASE DATEPART(weekday,dt) WHEN 1 THEN 0 WHEN 7 THEN 0 ELSE 1 END) AS 工作日
FROM
(SELECT DATEADD(dd,ID_NUM-1,getDATE()) AS dt FROM #t) AS a
WHERE dt<'2004-10-1'
DROP TABLE #t
SELECT
COUNT(*) AS 天数,SUM(CASE DATEPART(weekday,dt) WHEN 1 THEN 0 WHEN 7 THEN 0 ELSE 1 END) AS 工作日
FROM
(SELECT DATEADD(dd,ID_NUM-1,getDATE()) AS dt FROM #t) AS a
WHERE dt<'2004-10-1'
DROP TABLE #t