我照您说的建了一张表,然后通过关联查询也能查到我要的效果。但是存放工作日的话有没有简单点的方法,因为每周五天的工作日存起来比较繁琐。create table tb ( ID int primary key identity(1,1), Datetime varchar(50) ) insert into tb values('2015-01-26') insert into tb values('2015-01-27') insert into tb values('2015-01-28') insert into tb values('2015-01-29') insert into tb values('2015-01-30') insert into tb values('2015-02-02')select convert(varchar(10),Datetime,120) from tb where Datetime not in(select tb.Datetime from ManHour join tb on ManHour.DateTime=tb.Datetime where UserID='hailong.yang')
有个想法: 每次处理一个人, 把这个人在时间范围内的所有数据拿出来后, 进行比较,因为时间范围已知, 所以可以判断出哪些天没有记录. 而后再处理下一个人, 这样TSQL简单许多.
我照您说的建了一张表,然后通过关联查询也能查到我要的效果。但是存放工作日的话有没有简单点的方法,因为每周五天的工作日存起来比较繁琐。create table tb
(
ID int primary key identity(1,1),
Datetime varchar(50)
)
insert into tb values('2015-01-26')
insert into tb values('2015-01-27')
insert into tb values('2015-01-28')
insert into tb values('2015-01-29')
insert into tb values('2015-01-30')
insert into tb values('2015-02-02')select convert(varchar(10),Datetime,120) from tb where Datetime not in(select tb.Datetime from ManHour
join tb on ManHour.DateTime=tb.Datetime where UserID='hailong.yang')
然后节假日和串休特殊手动单独处理一下,能省点事不过在我看来,还不如直接在excel表里做好直接粘数据库里去,为了这点玩意做个程序怪费劲的,而且还没啥大用
然后节假日和串休单独处理的
不过这样做真的没啥意义
反正你一年才排一次,在excel表里做好,鼠标一拽,就自动出来了,比写循环判断省事多了