DBAsupport.com Forums - Powered by vBulletin
Results 1 to 2 of 2

Thread: Date validation

  1. #1
    Join Date
    Nov 2001
    Posts
    1

    Smile

    Hi all,

    pl. help me validating the DATE values.

    the values like this

    BATCH_START_DATE BATCH_END_DATE
    2/15/2001 5/10/2001
    6/1/2001 7/25/2001
    9/18/2001 12/31/2001
    1/1/2002 2/2/2002
    3/1/2001 6/5/2001


    The DATEs should be in sequence, means if i find any value
    that equals or between the dates which already existing in the table, i need to show that the whole record is not valid

    like 3/1/2001 and 6/5/2001 because already
    2/15/2001 and 5/10/2001 is existing in the table.


    how to write a sql ?

    thanks





  2. #2
    Join Date
    Dec 2000
    Location
    Ljubljana, Slovenia
    Posts
    4,439
    Code:
    SELECT * FROM dates_table dt WHERE EXISTS
      (SELECT null FROM dates_table 
         WHERE (batch_start_date BETWEEN
                  dt.batch_start_date AND dt.batch_end_date
                OR
                batch_end_date BETWEEN
                  dt.batch_start_date AND dt.batch_end_date
               )
         AND rowid < dt.rowid
      );
    [Edited by jmodic on 02-15-2002 at 05:34 PM]
    Jurij Modic
    ASCII a stupid question, get a stupid ANSI
    24 hours in a day .... 24 beer in a case .... coincidence?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width