[英]Query START_DATE is 1 day greater than the END_DATE
I have a table where i have two columns START_DATE and END_DATE.我有一个表,其中有两列 START_DATE 和 END_DATE。 I need to find out all the records where start date is 1 day greater than end date.
我需要找出开始日期比结束日期大 1 天的所有记录。
select *
from myTable
where end_date = start_date + 1
will show you all the rows where end_date
is exactly 1 day later than start_date
.将显示
end_date
比start_date
晚 1 天的所有行。
Be aware that Oracle date
columns always have a day and a time component, though, even if your front end isn't showing the time component.请注意,Oracle
date
列始终具有日期和时间组件,即使您的前端没有显示时间组件。 If end_date
and start_date
always have a time component of midnight, they might be exactly 1 day apart.如果
end_date
和start_date
始终具有午夜的时间分量,则它们可能正好相隔 1 天。 If they have actual times, though, it is very unlikely that they would be exactly 1 day apart.但是,如果他们有实际时间,那么他们不太可能正好相隔 1 天。 If you really want to see all rows where the day component differs by a day, ignoring the time component
如果您真的想查看日期分量相差一天的所有行,请忽略时间分量
select *
from myTable
where trunc(end_date) = trunc(start_date) + 1
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.