• SIJCOOKE - Friday, January 20, 2017 2:31 PM

    Hi all, thanks for any help given.
    I have a table with two columns and Date2...
    e.g.
    DateTime1           DateTime2
    1/1/2017 10:00       6/1/2017 13:00
    12/1/2017 08:00       20/1/2017 14:00
    5/2/2017 11:30   16/2/2017 20:15
    12/3/2017 09:15   19/3/2017 22:00
    ...etc, etc...
    Is it possible to write an sql statement to fill a table with the datetimes NOT within this two ranges.. e.g, the table would look like this:
    DateTime1               DateTime2
    6/1/2017 13:00        12/1/2017 08:00
    20/1/2017 14:00       5/2/2017 11:30
    16/2/2017 20:15       12/3/2017 09:15
    ...etc, etc...
    Any help with this would be appreciated,
    thanks,
    sijcooke  

    What do you mean? Find the timespan between the end of the previous record and the current record?  Also, please post create table and insert scripts for your table(s)... like this:
    CREATE TABLE TimeSpans(
    SpanID INT IDENTITY,
    StartTime DATETIME,
    EndTime DATETIME);

    INSERT INTO TimeSpans(StartTime, EndTime) VALUES
    ('12-Jan-2017 08:00', '20-Jan-2017 14:00')
    ,('5-Feb-2017 11:30', '16-Feb-2017 20:15')
    ,('12-Mar-2017 09:15', '19-Mar-2017 22:00')
    ,('1-Jan-2017 10:00', '6-Jan-2017 13:00');