Created
August 25, 2014 09:50
-
-
Save patmanv/17a3b50ba80dda26ffc2 to your computer and use it in GitHub Desktop.
Current Age (sql)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| DECLARE @startDate DATETIME = '20130703' | |
| DECLARE @endDate DATETIME = '20140703' | |
| IF ((MONTH(@endDate) * 100 + DAY(@endDate)) - (MONTH(@startDate) * 100 + DAY(@startDate))) >= 0 | |
| SELECT DATEDIFF(YEAR,@startDate, @endDate) | |
| ELSE | |
| SELECT DATEDIFF(YEAR,@startDate, @endDate) - 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment