June 7, 2010 at 9:47 pm
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.
June 7, 2010 at 10:37 pm
Hey there, Whats the relation between ABC and XYZ ?
June 7, 2010 at 10:47 pm
Please provide the sample Data for both table and expected output
June 7, 2010 at 11:05 pm
There is no relation ship between both tables.. just the date is stored in the the ABC table...
June 7, 2010 at 11:10 pm
June 7, 2010 at 11:12 pm
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
June 7, 2010 at 11:14 pm
Sir sorry for the Confusion..I have posted the test data...
Please let me know if you need any more Information
June 7, 2010 at 11:32 pm
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