Skip to content

Instantly share code, notes, and snippets.

@oluies
Created August 29, 2012 21:23
Show Gist options
  • Save oluies/3519165 to your computer and use it in GitHub Desktop.
Save oluies/3519165 to your computer and use it in GitHub Desktop.
Caculating number of weeks based on birthdates
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