Dear All,
Thanks For the response especially from Armando Talex. I tested the solution suggested by him; it's working fine.
But i found my own solution to solve this as follows:
--First drop the table.As i have created a procedure to do this calculation i am droping the table which is crated for temp purpose
drop table #date
--The below query will give me top 8 trading dates which are in the database & these dates will get store in a temp table #date
select top 8 tradedate into #date from EODNSE group by TradeDate order by TradeDate desc
--The below query will give me the enddate i.e. 8th trade date
select top 1 tradedate from #date order by tradedate
Following is the full queries to do this:
drop table #date
select top 8 tradedate into #date from EODNSE group by TradeDate order by TradeDate desc
declare @StartDate date
declare @Enddate date
set @StartDate = (select top 1 TradeDate from EODNSE order by TradeDate desc)
set @Enddate = (select top 1 tradedate from #date order by tradedate)