Can some one help with a case statement please, what I need is the query to show is the following. I know there are ways to do this easier but I just need help on the Case Statement.
--If the Current Month is ‘Less Than’ the DOB Month, then take ‘1’ of the Total Years to give me 41. --If the Current Month is ‘Greater Than’ the DOB Month then the Age is Correct. --However if the Current Month is ‘Equal’ to the DOB Month then we need to go to Day level to get the correct Age.
Set @DOB = '01 November 1971'
Set @Today = GETDATE()
SELECT Datediff(Year,@DOB,@Today) AS Years,
Datepart(Month,@DOB) As DOB_Month,
Datepart(Day, @DOB) as DOB_Day,
DatePart(Month, @Today) As Current_Month,
Datepart(Day,@Today) AS Current_Day