select
top
1
*
from
demotab
where
(
'
"&start_time&"
'
<=
start_time
and
'
"&end_time&"
'
>=
end_time)
or
--
判断新日期段与原日期段是否存在外包含
(
'
"&start_time&"
'
>=
start_time
and
'
"&end_time&"
'
<=
end_time)
or
--
判断新日期段与原日期段是否存在内包含
(
'
"&start_time&"
'
<=
start_time
and
'
"&end_time&"
'
<=
end_time
and
'
"&end_time&"
'
>=
start_time)
or
--
判断新日期段与原日期段是否存在左交叉
(
'
"&start_time&"
'
>=
start_time
and
'
"&start_time&"
'
<=
end_time
and
'
"&end_time&"
'
>=
end_time)
--
判断新日期段与原日期段是否存在右交叉
前提是输入的end_time是大于start_time
如果SQL语句有返回记录则日期有冲突,否则则正确!
如果SQL语句有返回记录则日期有冲突,否则则正确!
本文转自左正博客园博客,原文链接:http://www.cnblogs.com/soundcode/archive/2012/01/09/2316824.html,如需转载请自行联系原作者