请检查图像。 如果插入日期和时间,如何获取一条记录?
例如日期= 20180815时间= 231500 仅获取1条记录,什么是轮班日期?
答案 0 :(得分:0)
您想要这样的东西:
where (shiftstartdate = :datevar and
:datetime between shiftstarttime and shiftendtime
) or
(shiftenddate = :datevar and
:datetime between shiftendtime and shiftstarttime
)
更详细的版本可能使逻辑更清晰:
where (shiftstartdate = :datevar and
shiftenddate = shiftstartdate and
shiftstarttime < shiftendtime and
:datetime between shiftstarttime and shiftendtime
) or
(shiftenddate = :datevar and
shiftenddate <> shiftstartdate and
shiftstarttime > shiftendtime and
:datetime between shiftendtime and shiftstarttime
)