stephenyenchik
Programmer
Hello. I am trying to write a stored procedure that executes at midnight every night and checks an employee's hire date from one table and changes a field on another table if today's date is exactly 5 years greater than the start date and the hire date is after 1996.
Here is the code:
CREATE PROCEDURE [usp_check_hiredate]
AS
DECLARE @idfiveyear [int]
SET @idfiveyear=(SELECT DISTINCT id from t_user where hire_date = DATEADD(yy, -5, GETDATE()) AND YEAR(hire_date)>1996)
UPDATE t_timeoff
SET accrual_rate=4.69 WHERE user_id=@idfiveyear and type='vacation'
GO
It's not doing it. Can anyone help me?
S
Here is the code:
CREATE PROCEDURE [usp_check_hiredate]
AS
DECLARE @idfiveyear [int]
SET @idfiveyear=(SELECT DISTINCT id from t_user where hire_date = DATEADD(yy, -5, GETDATE()) AND YEAR(hire_date)>1996)
UPDATE t_timeoff
SET accrual_rate=4.69 WHERE user_id=@idfiveyear and type='vacation'
GO
It's not doing it. Can anyone help me?
S