select userid from tb where logintime between getdate() and dateadd(day,-6,getdate())
group by userid
having count(distinct convert(char(10),logintime,120))=7
group by userid
having count(distinct convert(char(10),logintime,120))=7
select distinct userid , convert(varchar(10),logintime,120) from tb where datediff(day,logintime,getdate()) <= 7
group by userid , convert(varchar(10),logintime,120)
having count(*) = 7
insert @t select 1,getdate()
insert @t select 1,getdate()-1
insert @t select 1,getdate()-2
insert @t select 1,getdate()-3
insert @t select 1,getdate()-4
insert @t select 1,getdate()-5
insert @t select 1,getdate()-6
insert @t select 1,getdate()-7
insert @t select 2,getdate()
insert @t select 2,getdate()-2
insert @t select 2,getdate()-2
insert @t select 2,getdate()-3
insert @t select 2,getdate()-4
insert @t select 2,getdate()-5
insert @t select 2,getdate()-6
insert @t select 2,getdate()-7
insert @t select 3,getdate()
insert @t select 3,getdate()
insert @t select 3,getdate()select id from @t where d >=dateadd(day,-6,convert(char(10),getdate(),120))
group by id
having count(distinct convert(char(10),d,120))=7
/*
id
-----------
1
*/