尝试在一段时间内选择两个日期之间的行

trying to selecting rows that are between two date for a period of time

这个问题就像一个脑筋急转弯....所以我有两个日期,开始日期和结束日期,我想 select 这两个日期之间的所有活动行,如果期间在这些日期之间已经过去,那么不应 select 编辑这些行。请注意,这些日期包括时间

Here is an example before the code Start date = '15-MAY-2020 08:00 AM' and End date = '16-MAY-2020 08:00 AM'

As you can see there is 24 hour period between those dates and i want to select ALL ROWS THAT ARE BETWEEN THE START DATE AND END DATE and if the the time becomes '16-MAY-2020 08:01 AM' then those rows should not be displayed anymore.

现在代码

select id, title, color, start_date, end_date 
from colors
where end_date >= start_date and end_date <= sysdate

总结: 如果颜色介于某个开始和结束之间,则它只能在该开始和结束期间显示,否则不应显示 这就像吃冰淇淋,你拿到冰淇淋然后开始吃它(开始)然后你一直吃到它吃完(结束)然后你就没有冰淇淋了 与颜色相同,它在特定日期和时间开始显示,并在特定日期和时间结束,之后颜色不再显示

你很接近。你的两个条件都需要参考sysdate:

select id, title, color, start_date, end_date 
from colors
where start_date <= sysdate and end_date >= sysdate