tags:

views:

54

answers:

2

hello, I have stored procedure getList(@date datetime)

how programmatically execute stored procedure for differend datetime values.

datetime each month for 3 years.

Any idea, please.

A: 

Just add one month to the current date?

DATEADD(month, 1, GETDATE())
JonH
you mean 12*3=36 times i manually must add to parameter?
loviji
im not sure what you mean, you have a date right? All you have to do is take that date and add one month to it. EXEC(@YourDateParameter) SELECT @YourDateParameter = DATEADD(month, 1, @YourDateParameter)
JonH
+5  A: 

You can try something like this

DECLARE @StartDate DATETIME,
     @EndDate DATETIME

SELECT  @StartDate = '01 Jan 2005',
     @EndDate = '31 Dec 2007'

WHILE @StartDate <= @EndDate
BEGIN
    PRINT @StartDate
    EXEC getList(@StartDate)
    SET @StartDate = DATEADD(mm, 1, @StartDate)
END
astander
thanks, for answer.
loviji