Last active
May 23, 2016 15:38
-
-
Save afreeland/4eb18990d784c87bd3379642999d72c1 to your computer and use it in GitHub Desktop.
SQL: Month name from number
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
-- Renders out May | |
Select DateName(month, DateAdd(month, 5, -1)) | |
-- https://msdn.microsoft.com/en-us/library/ms174395.aspx | |
-- DateName(datepart, date) | |
-- https://msdn.microsoft.com/en-us/library/ms186819.aspx | |
-- DateAdd(datepart, number, date) | |
-- @datepart - the particular part of the date (year, month, etc.,) that will be incremented by an integer | |
-- @number - the month we are targeting | |
-- @date - An integer that will return back a particular date | |
-- @example | |
-- select DateAdd(month, 5, 0) -1 | |
-- select DateAdd(month, 5, -1) | |
-- ** both return 1900-05-31 00:00:00.000 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment