Thursday, December 1, 2011

Get your's Birthday details Year, Quarters, Months, Weeks, Days, Hours, Minutes & Seconds in SQL

DECLARE @StartDate SMALLDATETIME

SET @StartDate = '01/08/1985 1:35:00' -- Put Your Date of Birth & Time

SELECT DATEDIFF(yyyy, @StartDate, GETUTCDATE()) Years,
DATEDIFF(qq, @StartDate, GETUTCDATE()) AS Quarters,
DATEDIFF(mm, @StartDate, GETUTCDATE()) AS Months,
DATEDIFF(ww, @StartDate, GETUTCDATE()) AS Weeks,
DATEDIFF(dd, @StartDate, GETUTCDATE()) AS [Days],
DATEDIFF(hh, @StartDate, GETUTCDATE()) AS [Hours],
DATEDIFF(mi, @StartDate, GETUTCDATE()) AS [Minutes],
DATEDIFF(ss, @StartDate, GETUTCDATE()) AS [Seconds]

No comments:

Post a Comment