How automatically add 1 year date to an existing date in SQL Server

sql, sql-server, t-sql

Solution

Use DATEADD, i.e.:

SELECT DATEADD(year, 1, '2006-08-30')

Ref.: http://msdn.microsoft.com/en-us/library/ms186819.aspx

Problem

I have a task to automatically bill all registered patients in `PatientsInfo` table an Annual Bill of N2,500 base on the `DateCreated` column. Certainly I will use a stored procedure to insert these records into the `PatientDebit` table and create a SQL Job to perform this procedure. How will I `select *` patients in `PatientsInfo` table where `DateCreated` is now 1 yr old for me to insert into another table `PatientDebit`. I have my algorithm like this: - select date of registration for patients from `PatientsInfo` table - Add 1 year to their `DateCreated` - Is date added today? if yes, - Insert record into `PatientDebit` table with the bill of N2,500 - If no, do nothing. Please how do I write the script?

Original source