I am at the very beginnings of my IT and Database experience, fortunately landed an IT Coordinator job. I am tasked with the responsibility of pulling contacts to run through our text manager service. I'll need to run birthdays according to the current date. Pull the list from the Contacts table which should contain all the necessary info needed. Full Name, DOB, and Mobile number. Using SQL Server.
Not entirely sure how the query would look, wondering how you guys would run this. I figured it would go along the lines of selecting those columns from the table in regard to today's (or whenever it is run) date. Those that have birthdays today would get a birthday text sent out to them.
Would this be a viable query? I know this could be entirely wrong. Any criticism and help is much appreciated! Thank you in advance.
SELECT InformalName, LastName, Birthdate, MobilePhone from Contact
WHERE DAY(BirthDate) = DAY(GETDATE())
AND MONTH(BirthDate) = MONTH(GETDATE())
AND MobilePhone like '(%'
This seems to pull all the necessary information I will need. Just looking to see if there is room for improvement, or if this should suffice. This query is strictly to pull birthdays for the current date to send out "Happy Birthday!" messages through our text message service.
DATEPART
function?