He utilizado la fecha y hora de la validación de la programación de un informe ... tengo que programar para que los informes de fecha futura y el tiempo solamente y no la fecha anterior y time..I han utilizado esteError de comparación de fecha y hora en sql?
declare @Dt varchar(50)
declare @Hr varchar(50)
declare @trandate_time_tmp as TIME(0)
select @trandate_time_tmp = getdate()
set @Dt = DATEDIFF (D,@schedule_date ,@trandate_tmp)
set @Hr = DATEDIFF (S,@schedule_date ,@trandate_time_tmp)
if (@Dt > 0)
begin
raiserror('Schedule Date should not be earlier than system date',16,1)
return
end
if (@Hr > 0)
begin
raiserror('Schedule Time should not be earlier than system time',16,1)
return
end
Por parte de fecha se está comprobando correctamente, pero por el tiempo que está lanzando el error como
The datediff function resulted in an overflow. The number of dateparts separating two date/time instances is too large. Try to use datediff with a less precise datepart.
'set @Hr = DATEDIFF (S, @ schedule_date, @ trandate_time_tmp)'. Aquí. Estás tratando de obtener la diferencia en segundos mientras la asignas a una variable llamada '@ Hr'. ¿No necesitas 'HH' en lugar de' S'? Además, ¿por qué usar un varchar para '@ Hr'? – shahkalpesh