Not sure what I was missing. The same function is now working as expected. Below is the content of my function(ofcourse elaborated, which is not needed though). Bottom line, it is working fine now.
Once again thank you so much for taking time and effort to check this for me!!
IF OBJECT_ID (N'dbo.maskdOB', N'FN') IS NOT NULL
DROP FUNCTION maskdOB;
GO
CREATE FUNCTION dbo.[maskdOB]
(
-- Add the parameters for the function here
@DOB as datetime
)
RETURNS Datetime
AS
BEGIN
Declare @maskedDt datetime
Select @maskedDt = case when month(@DOB) = 2 and year(@DOB)%4=0 and day(@DOB) = 29 then dateadd(day,1,@DOB)
when month(@DOB) = 2 and year(@DOB)%4<>0 and day(@DOB) = 28 then dateadd(day,1,@DOB)
when month(@DOB) in (1,3,5,7,8,10,12) and day(@DOB) = 31 then dateadd(day,1,@DOB)
when month(@DOB) in (4,6,9,11) and day(@DOB) = 30 then dateadd(day,1,@DOB)
when month(@DOB) = 2 and day(@DOB) not in (28,29) then dateadd(day,29,@DOB)
when month(@DOB) in (1,3,5,7,8,10,12) and day(@DOB) <> 31 then dateadd(day,32,@DOB)
when month(@DOB) in (4,6,9,11) and day(@DOB) <> 30 then dateadd(day,31,@DOB)
else '' end
-- Return the result of the function
RETURN @maskedDt
END