SQL Server/T-SQL Tutorial/Date Functions/Day

Материал из SQL эксперт
Перейти к: навигация, поиск

Displaying the Integer Value For Part of a Date using DAY

3>
4> SELECT DAY(GETDATE())
5> GO
-----------
         19
(1 rows affected)
1>


select DAY("2002-09-30")

2> select DAY("2002-09-30")
3> GO
-----------
         30
(1 rows affected)
1>


YEAR, MONTH, DAY

5>
6> SELECT "Year: " + CONVERT(VarChar(4), YEAR(GETDATE()))
7>  ", Month: " + CONVERT(VarChar(2), MONTH(GETDATE()))
8>  ", Day: " + CONVERT(VarChar(2), DAY(GETDATE()))
9>
10> GO
Msg 102, Level 15, State 1, Server J\SQLEXPRESS, Line 7
Incorrect syntax near "+".