select *
from
(
select 日期 from a
except
select 日期 from b
)a
union all
select *
from
(
select 日期 from b
except
select 日期 from a
)a
from
(
select 日期 from a
except
select 日期 from b
)a
union all
select *
from
(
select 日期 from b
except
select 日期 from a
)a
select t.日期
from
(
select 日期 from A
union
select 日期 from B
)t
left join A
on a.日期 = t.日期
left join B
on b.日期 = t.日期
where a.日期 is null or b.日期 is null
/*
日期
2013-11-01 00:00:00.000
2013-11-01 00:00:00.000
*/
select '2013-10-30 00:00:00.000' union all
select '2013-10-30 00:00:00.000' union all
select '2013-10-30 00:00:00.000' union all
select '2013-10-30 00:00:00.000'
create table B(日期 datetime)insert into B
select '2013-10-30 00:00:00.000' union all
select '2013-10-30 00:00:00.000' union all
select '2013-10-30 00:00:00.000' union all
select '2013-10-30 00:00:00.000' union all
select '2013-11-01 00:00:00.000' union all
select '2013-11-01 00:00:00.000'
go
select t.日期
from
(
select 日期 from A
union
select 日期 from B
)t
left join A
on a.日期 = t.日期
left join B
on b.日期 = t.日期
where a.日期 is null or b.日期 is null
/*
日期
2013-11-01 00:00:00.000
2013-11-01 00:00:00.000
*/
还需要加日期起止条件来对比
日期>='20131001' and 日期<='20140131'
这样的,适合sql server 2000的,你试试:create table A(日期 datetime)insert into A
select '2013-10-30 00:00:00.000' union all
select '2013-10-30 00:00:00.000' union all
select '2013-10-30 00:00:00.000' union all
select '2013-10-30 00:00:00.000'
create table B(日期 datetime)insert into B
select '2013-10-30 00:00:00.000' union all
select '2013-10-30 00:00:00.000' union all
select '2013-10-30 00:00:00.000' union all
select '2013-10-30 00:00:00.000' union all
select '2013-11-01 00:00:00.000' union all
select '2013-11-01 00:00:00.000'
go
select t.日期
from
(
select 日期 from A
union
select 日期 from B
)t
left join A
on a.日期 = t.日期
left join B
on b.日期 = t.日期
where a.日期 is null or b.日期 is null
and t.日期>='20131001' and t.日期<='20140131'
/*
日期
2013-11-01 00:00:00.000
2013-11-01 00:00:00.000
*/