thirdrockit
asked on
SQL Query Alert 30 Day Reminder
I have a SQL Database that is back end to a program we use for accounting and business mgt. Inside the program, we can write multiple alerts based on query's of the data stored in SQL. The current query i have written displays an alert when someone has a birthday.
set transaction isolation level read uncommitted
SELECT
AlertMessage = 'Happy Birthday '+firstname+' '+lastname+' !!'
FROM dbo.Employees
WHERE DATEPART(d, birthdate) <= DATEPART(d, GETDATE())
AND DATEPART(m, birthdate) = DATEPART(m, GETDATE())
I would like to modify it so that it shows the alert 30 days before the birthday is going to happen.
set transaction isolation level read uncommitted
SELECT
AlertMessage = 'Happy Birthday '+firstname+' '+lastname+' !!'
FROM dbo.Employees
WHERE DATEPART(d, birthdate) <= DATEPART(d, GETDATE())
AND DATEPART(m, birthdate) = DATEPART(m, GETDATE())
I would like to modify it so that it shows the alert 30 days before the birthday is going to happen.
ASKER
after running it, it shows 2 people who had a birthday yesterday 10/9. If there birthday has already passed, should the alert still run?
ASKER
In other words, it needs to alert for 30 days and then on the day, don't alert anymore.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I declared @current_date as integer. The query ran with no errors but it doesn't give me any results.
Open in new window