This function can be used to calculate the Age on a particular date.
CREATE FUNCTION dbo.FindAge
(
@Dob DATETIME,
@ToDate DATETIME
)
RETURNS INT
AS
BEGIN
RETURN ROUND((CASE
WHEN @dob > @ToDate
THEN NULL
WHEN DATEPART(day, @dob) > DATEPART(day, @ToDate)
THEN DATEDIFF(month, @dob, @ToDate) - 1
ELSE DATEDIFF(month, @dob, @ToDate)
END / 12), 0);
END;
Please refer why you should not use DATEDIFF function directly and use above logic.
Cheers!
Uma
slot situs
ReplyDeleteslot terpercaya gacor
web slot gacor
agen togel online
bandar togel online