The DAY(), MONTH(), and YEAR() Functions : Year « Date Timezone « SQL Server / T-SQL






The DAY(), MONTH(), and YEAR() Functions


1>
2> -- The DAY(), MONTH(), and YEAR() Functions
3>
4> -- These three functions return an integer date part of a DateTime or SmallDateTime --
5> -- type value.
6>
7>
8> SELECT 'Year: ' + CONVERT(VarChar(4), YEAR(GETDATE()))
9>    + ', Month: ' + CONVERT(VarChar(2), MONTH(GETDATE()))
10>    + ', Day: ' + CONVERT(VarChar(2), DAY(GETDATE()))
11>
12> GO

------------------------------
Year: 2006, Month: 10, Day: 12

(1 rows affected)
1>
           
       








Related examples in the same category

1.YEAR: return the year portion of a date
2.Using Functions in Queries
3.select YEAR('2002-09-30')