SQL Server - DAY() , MONTH(), YEAR() Functions

SQL Server Day, Month, Year Functions

If you need to extract a portion of the date you can use one of these three functions. You can also use the datepart or datename functions to accomplish the same task. Note that the DAY() and Month() functions will return the the respective day or month without a leading zero.

SELECT TOP 1
   DAY(GETDATE())       AS "DAY()" 
  ,MONTH(GETDATE())     AS "MONTH()" 
  ,YEAR(GETDATE())      AS "YEAR()"   
FROM AdventureWorks2008R2.Sales.Store
 Collapse All    Expand All
Custom Search

SQL Server Information and Resources