3个回答
展开全部
首先保证,a 与 b 表的时间是 date 或者 datetime 类型:
1、Oracle 写法:
select sum (case when to_char(a.time,'d')-1>=1 and to_char(a.time,'d')-1<=5 then 1
else 0
end)
from tablename a;
2.MSSQL 和 Sybase 写法:
select sum(case when datepart(weekday,a.datetime)-1 >=1 and datepart(weekday,a.datetime)-1<=5 then 1
else 0
end)
from tablename a
1、Oracle 写法:
select sum (case when to_char(a.time,'d')-1>=1 and to_char(a.time,'d')-1<=5 then 1
else 0
end)
from tablename a;
2.MSSQL 和 Sybase 写法:
select sum(case when datepart(weekday,a.datetime)-1 >=1 and datepart(weekday,a.datetime)-1<=5 then 1
else 0
end)
from tablename a
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
declare @a datetime
declare @b datetime
declare @c int
set @a = '2012-07-01'
set @b = GETDATE()
if(DATEPART(WEEKDAY, @a)=1 or DATEPART(WEEKDAY, @a)=7)
set @c = DATEDIFF(DAY, @a, @b)/7 * 5
else
set @c = (DATEDIFF(DAY, @a, @b)/7 * 5) + DATEDIFF(DAY, @a, @b) % 7 - 2
select @c
这样就OK
declare @b datetime
declare @c int
set @a = '2012-07-01'
set @b = GETDATE()
if(DATEPART(WEEKDAY, @a)=1 or DATEPART(WEEKDAY, @a)=7)
set @c = DATEDIFF(DAY, @a, @b)/7 * 5
else
set @c = (DATEDIFF(DAY, @a, @b)/7 * 5) + DATEDIFF(DAY, @a, @b) % 7 - 2
select @c
这样就OK
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2015-06-26
展开全部
declare @a datetime
declare @b datetime
declare @c int
set @a = '2012-07-01'
set @b = GETDATE()
if(DATEPART(WEEKDAY, @a)=1 or DATEPART(WEEKDAY, @a)=7)
set @c = DATEDIFF(DAY, @a, @b)/7 * 5
else
set @c = (DATEDIFF(DAY, @a, @b)/7 * 5) + DATEDIFF(DAY, @a, @b) % 7 - 2
。
declare @b datetime
declare @c int
set @a = '2012-07-01'
set @b = GETDATE()
if(DATEPART(WEEKDAY, @a)=1 or DATEPART(WEEKDAY, @a)=7)
set @c = DATEDIFF(DAY, @a, @b)/7 * 5
else
set @c = (DATEDIFF(DAY, @a, @b)/7 * 5) + DATEDIFF(DAY, @a, @b) % 7 - 2
。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询