Skip to content

Instantly share code, notes, and snippets.

@ArCiGo
Created May 19, 2019 22:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ArCiGo/0ff3549f1cb65862e635f8368b2b0340 to your computer and use it in GitHub Desktop.
Save ArCiGo/0ff3549f1cb65862e635f8368b2b0340 to your computer and use it in GitHub Desktop.
SELECT GETDATE();
GO
/** Output **/
-----------------------
2017-03-20 16:57:22.273
SELECT DATEPART(yy, ord.OrderDate)
FROM [ORDER] ord;
GO
/** Output **/
2014
2014
2014
2014
2014
2014
2014
...
SELECT DATEADD(mm, 1, GETDATE());
GO
/** Output **/
-----------------------
2017-04-20 16:59:18.760
SELECT MONTH('20170426');
GO
/** Output **/
-----------
4
SELECT DAY('20170426');
GO
/** Output **/
-----------
26
SELECT YEAR('20170426');
GO
/** Output **/
-----------
2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment