简体   繁体   中英

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. I need to find out all the records where start date is 1 day greater than end date.

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 .

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. If end_date and start_date always have a time component of midnight, they might be exactly 1 day apart. If they have actual times, though, it is very unlikely that they would be exactly 1 day apart. 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM