Sunday, February 19, 2012

Error to execute a procedure in a job

Hi
I only speak a little english. I wait that you can undenstand me.
I hava a sql how this:
--Cálculo de la Fecha Inicial
DECLARE @.FechaInicial varchar(10)
SET @.FechaInicial = '01'+'/' + replace(str(Month(getDate()),2) ,' ','0') +
'/' + Cast(Year(getDate()) as varchar(4))
--Cálculo de la Fecha Final
DECLARE @.Ano as int
DECLARE @.Mes as int
DECLARE @.DiaFinMes as int
DECLARE @.FechaFinal varchar(10)
SET @.Ano = Year(getDate())
SET @.Mes = Month(getDate())
SET @.DiaFinMes = dbo.DiaFinalMes (@.Ano,@.Mes)
SET @.FechaFinal = cast(@.DiaFinMes as varchar(2))+ '/' +
replace(str(Month(getDate()),2),' ','0') + '/' + Cast(Year(getDate()) as
varchar(4))
--Cálculo del día acutal
DECLARE @.DiaActual as varchar(2)
SET @.DiaActual = replace(str(Day(getDate()),2),' ','0')
--Ejecutar
execute SeguimientoComercialCargaDatos
'100',@.FechaInicial,@.FechaFinal,@.DiaActual
In this sql, I get some dates how parameters of the procedure. If I execute
it the
result is correct, but, if I make a new step of a job whith the same
content the procedure returns me wrong datas.
Thank you veri much.Hi Jose,
you now the dateadd function?
DATEADD ( datepart , number, date )
like this
DECLARE
@.DATE1 DATETIME,
@.DATE2 DATETIME
SET @.DATE1 = GetDate()
@.DATE2 = DATEADD(day, 31, @.DATE1)

No comments:

Post a Comment