Created
August 29, 2012 21:23
-
-
Save oluies/3519165 to your computer and use it in GitHub Desktop.
Caculating number of weeks based on birthdates
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
SELECT | |
calendar_date birth_date, | |
current_date - birth_date Diff_Days, | |
CASE WHEN Diff_Days >= 0 THEN (Diff_Days)/7 | |
ELSE (Diff_Days +1) / 7 - 1 END | |
FROM sys_calendar.calendar | |
ORDER BY 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment