Skip to Main Content
  • Questions
  • Overlapping date check with one date null

Breadcrumb

Question and Answer

Tom Kyte

Thanks for the question, jaggu.

Asked: April 29, 2004 - 12:05 pm UTC

Last updated: April 30, 2004 - 5:21 am UTC

Version: 9.2.0

Viewed 1000+ times

You Asked

Hi Mr Tom,

I had gone through the concept of avoiding overlapping dates...it really helps me but in addition to that i want one extra check in that i.e in my scenario date_to can be null.

Suppose i already have :

date_from date_to
01.04.2004 10.04.2004
20.04.2004 ----->>date_to is null

Now in if anybody wants to insert

25.04.2004 30.04.2004 ---->>>Not allowed because these dates are greater that 20.4.2004

15.04.2004 17-04-2004 ---->>>Allowed because dates are less that 20.4.2004

18.4.2004 ---->>>Not allowed ,in this case date_to is mandatory and should be less than 20.4.2004


If i Summarize then if at any instance date_to is null then further records are not allowed which are greater than date_from(as in above 20.4.2004) but less than date_from records are allowed .If records are less than in that case date_to is mandatory.

Looking at this could you please help to sort it out.

Thanks




and Tom said...

use nvl(date_to,to_date('01-jan-3000','dd-mon-yyyy')) in place of just "date_to" then.

default a null date_to to be some date way out into the future.

Rating

  (1 rating)

Is this answer out of date? If it is, please let us know via a Comment

Comments

It works

jaggu, April 30, 2004 - 5:21 am UTC

Thanks to u