I'm having more issues. It's only pulling back 2 users even though I know I have more than 5 with birthdates. Also I'm having an issue with another field.
I added 2 custom fields - Country and HireDate. I can add Country to the query no problem and pull it back in the Transformation.
But when I change the query to search by HireDate instead of UserDateOfBirth, nothing gets returned. I know HireDate is in CMS_UserSettings. What about this is wrong??
SELECT TOP 10
FullName, UserSettingsUserGUID, Country, HireDate as EventDate, Today, CurrBDate,
CASE
WHEN joinedresults.CurrBDate <= joinedresults.Today THEN NextBDate
ELSE joinedresults.CurrBDate
END AS BirthDay
FROM
(
SELECT
u.FullName, usersettings.UserSettingsUserGUID, usersettings.HireDate,
usersettings.Today, Country,
DateAdd(Day,(CASE
WHEN DAY(usersettings.HireDate)=29 AND DAY(usersettings.CurrBDate)=28 THEN 1
ELSE 0
END), CurrBDate) AS CurrBDate,
DateAdd(Day,(CASE
WHEN DAY(usersettings.HireDate)=29 AND DAY(usersettings.NextBDate)=28 THEN 1
ELSE 0
END), NextBDate) AS NextBDate
FROM
(
SELECT
UserSettingsUserGUID, HireDate, Country,
CAST(Convert(CHAR(8), GETDATE(),112) AS DateTime) AS Today,
DateAdd(Year,DateDiff(year,HireDate, GETDATE()),HireDate) AS CurrBDate,
DateAdd(Year,DateDiff(year,HireDate, GETDATE()) + 1,HireDate) AS NextBDate
FROM
CMS_UserSettings
WHERE HireDate IS NOT NULL
) AS usersettings
LEFT JOIN CMS_User u on u.UserGUID = usersettings.UserSettingsUserGUID
) AS joinedresults
WHERE CurrBDate >= Today
ORDER BY CurrBDate