Records between 2 Dates

  • Hi,

    Could someone help me with the following Query

    I have a table abc with columns (A INT, LastExecutedDate Datetime)

    and I have a table XYZ with Column Created_Date and some other columns...

    I would like to get all the records and Columns from XYZ table where created_Date between 9.30 P.M of JobRunDate and GetDate 9.30 Pm.

    Please help me with the Sql Query

    Thanks.

  • Hey there, Whats the relation between ABC and XYZ ?

  • Please provide the sample Data for both table and expected output

  • There is no relation ship between both tables.. just the date is stored in the the ABC table...

  • I really cant understand your request, Lucky! Please provide us sample data, sample tables and a clear-desired result.. Please read thro this article on how to post data so that u get tested code back - CLICK HERE FOR FORUM POSTING ETIQUETTES - JEFF MODEN[/url]

  • Sample Data

    Table ABC

    A LastExecutedDate

    1 06/03/2010

    Table XYZ

    T U CreateDate

    1 2 06/03/2010 9.30 P.M

    2 4 06/03/2010 10.50 P.M

    3 5 06/04/2010 9.25 P.M

    5 9 06/04/2010 9.50 P.M

    I should get rows with T column values 1,2 and 3 and exclude the row with T value 5 as it comes the next day after 9.30 P.M from the table XYZ

    So basically there is no relationship between the 2 tables.. we are just storing the date ...it is like look up table.

    basically i need data from 9.30 P.M of job last executed date to getdate() 9.30 P.M

  • Sir sorry for the Confusion..I have posted the test data...

    Please let me know if you need any more Information

  • I think This may be help u

    DECLARE @Date datetime

    Declare @EndDate DateTime

    Set @Date = DateAdd(mi,570,'06/03/2010') -- Fetch this Data from the table ABC

    set @EndDate = DateAdd(day,1,@Date)

    select * from xyz where CreateDate between @Date and @EndDate

Viewing 8 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic. Login to reply