this result is needed
gft.dbo.GFT_Jan14
gft.dbo.GFT_Dec13
gft.dbo.GFT_Nov13
gft.dbo.GFT_Oct13
gft.dbo.GFT_Sep13
my query is as below
DECLARE @qry VARCHAR(max)
DECLARE @tab1 VARCHAR(max)
DECLARE @tab2 VARCHAR(max)
DECLARE @tab3 VARCHAR(max)
DECLARE @tab4 VARCHAR(max)
DECLARE @tab5 VARCHAR(max)
DECLARE @stvar VARCHAR(50)
SET @stvar = 'gft.dbo.GFT_'
SET @tab1 = @stvar + left(DATENAME(MONTH, GETDATE() - 1), 3) + right(YEAR(getdate() - 1), 2)
SET @tab2 = @stvar + left(DATENAME(MONTH, GETDATE() - 35), 3) + right(YEAR(getdate() - 35), 2)
SET @tab3 = @stvar + left(DATENAME(MONTH, GETDATE() - 70), 3) + right(YEAR(getdate() - 70), 2)
SET @tab4 = @stvar + left(DATENAME(MONTH, GETDATE() - 100), 3) + right(YEAR(getdate() - 100), 2)
SET @tab5 = @stvar + left(DATENAME(MONTH, GETDATE() - 130), 3) + right(YEAR(getdate() - 130), 2)
problem is while fixing days 1,35, 70, 100, 130
can anyone tell me how use months instead of days so that
feburary and 31st 30th days can be auto adjusted??
somthing like this logic can be used and how??
set @tableName= 'gft.dbo.GFT_' + 'Month(getdate() - 1 month)
set @tableName= 'gft.dbo.GFT_' + 'Month(getdate() - 2 months)
set @tableName= 'gft.dbo.GFT_' + 'Month(getdate() - three months)