如何在oracle sql上获取日期范围?

时间:2021-03-06 01:43:14

I have table with column say

我有专栏的表说

start_date   |end_date
21-NOV-2014  |  23-DEC-2014
01-JAN-2015  |   null
01-JUNE-2014 | 03-MAR-2015
01-DEC-2014  | 29-DEC-2014

if i give 01-DEC-2014 it has to pick dates which are overlapping in the date range. In this case it hase to pick 1,3,4th record. But if i give 04-JAN-2015 it should pick all records.

如果我给01-DEC-2014,它必须选择在日期范围内重叠的日期。在这种情况下,它需要选择1,3,4记录。但如果我在2015年1月4日给它,它应该选择所有记录。

1 个解决方案

#1


1  

WHERE YOUR_DATE_VALUE BETWEEN START_DATE AND NVL(END_DATE,YOUR_DATE_VALUE)

The above should work! Defaulting end date as your date inputitself, in case of null (NVL())!

以上应该工作!将结束日期默认为您的日期输入,如果为null(NVL())!

#1


1  

WHERE YOUR_DATE_VALUE BETWEEN START_DATE AND NVL(END_DATE,YOUR_DATE_VALUE)

The above should work! Defaulting end date as your date inputitself, in case of null (NVL())!

以上应该工作!将结束日期默认为您的日期输入,如果为null(NVL())!