Last active
December 11, 2015 16:28
-
-
Save RexGibson/4627739 to your computer and use it in GitHub Desktop.
WEEK and YEARWEEK SQL Functions with dates to understand how different formats display
This file contains 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 YEARWEEK('2012-1-1', 0) '2012-1-1' | |
, YEARWEEK('2012-12-30', 0) '2012-12-30' | |
, YEARWEEK('2012-12-31', 0) '2012-12-31' | |
, YEARWEEK('2013-1-1', 0) '2013-1-1' | |
, YEARWEEK('2013-1-5', 0) '2013-1-5' | |
, YEARWEEK('2013-1-6', 0) '2013-1-6' | |
, 0 type | |
UNION | |
SELECT YEARWEEK('2012-1-1', 1) '2012-1-1' | |
, YEARWEEK('2012-12-30', 1) '2012-12-30' | |
, YEARWEEK('2012-12-31', 1) '2012-12-31' | |
, YEARWEEK('2013-1-1', 1) '2013-1-1' | |
, YEARWEEK('2013-1-5', 1) '2013-1-5' | |
, YEARWEEK('2013-1-6', 1) '2013-1-6' | |
, 1 type | |
UNION | |
SELECT YEARWEEK('2012-1-1', 2) '2012-1-1' | |
, YEARWEEK('2012-12-30', 2) '2012-12-30' | |
, YEARWEEK('2012-12-31', 2) '2012-12-31' | |
, YEARWEEK('2013-1-1', 2) '2013-1-1' | |
, YEARWEEK('2013-1-5', 2) '2013-1-5' | |
, YEARWEEK('2013-1-6', 2) '2013-1-6' | |
, 2 type | |
UNION | |
SELECT YEARWEEK('2012-1-1', 3) '2012-1-1' | |
, YEARWEEK('2012-12-30', 3) '2012-12-30' | |
, YEARWEEK('2012-12-31', 3) '2012-12-31' | |
, YEARWEEK('2013-1-1', 3) '2013-1-1' | |
, YEARWEEK('2013-1-5', 3) '2013-1-5' | |
, YEARWEEK('2013-1-6', 3) '2013-1-6' | |
, 3 type | |
UNION | |
SELECT YEARWEEK('2012-1-1', 4) '2012-1-1' | |
, YEARWEEK('2012-12-30', 4) '2012-12-30' | |
, YEARWEEK('2012-12-31', 4) '2012-12-31' | |
, YEARWEEK('2013-1-1', 4) '2013-1-1' | |
, YEARWEEK('2013-1-5', 4) '2013-1-5' | |
, YEARWEEK('2013-1-6', 4) '2013-1-6' | |
, 4 type | |
UNION | |
SELECT YEARWEEK('2012-1-1', 5) '2012-1-1' | |
, YEARWEEK('2012-12-30', 5) '2012-12-30' | |
, YEARWEEK('2012-12-31', 5) '2012-12-31' | |
, YEARWEEK('2013-1-1', 5) '2013-1-1' | |
, YEARWEEK('2013-1-5', 5) '2013-1-5' | |
, YEARWEEK('2013-1-6', 5) '2013-1-6' | |
, 5 type | |
UNION | |
SELECT YEARWEEK('2012-1-1', 6) '2012-1-1' | |
, YEARWEEK('2012-12-30', 6) '2012-12-30' | |
, YEARWEEK('2012-12-31', 6) '2012-12-31' | |
, YEARWEEK('2013-1-1', 6) '2013-1-1' | |
, YEARWEEK('2013-1-5', 6) '2013-1-5' | |
, YEARWEEK('2013-1-6', 6) '2013-1-6' | |
, 6 type | |
UNION | |
SELECT YEARWEEK('2012-1-1', 7) '2012-1-1' | |
, YEARWEEK('2012-12-30', 7) '2012-12-30' | |
, YEARWEEK('2012-12-31', 7) '2012-12-31' | |
, YEARWEEK('2013-1-1', 7) '2013-1-1' | |
, YEARWEEK('2013-1-5', 7) '2013-1-5' | |
, YEARWEEK('2013-1-6', 7) '2013-1-6' | |
, 7 type | |
; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment