datename in sql

Solutions on MaxInterview for datename in sql by the best coders in the world

showing results for - "datename in sql"
Joshua
29 May 2019
1SQL Server DATENAME() Function:
2Return a specified part of a date:
3
4SELECT DATENAME(year, '2017/08/25') AS DatePartString;
5
6Syntax
7DATENAME(interval, date)
8
9Parameter Values
10Parameter	Description
11
12interval	Required. The part to return. Can be one of the following values:
13
14year, yyyy, yy = Year
15quarter, qq, q = Quarter
16month, mm, m = month
17dayofyear = Day of the year
18day, dy, y = Day
19week, ww, wk = Week
20weekday, dw, w = Weekday
21hour, hh = hour
22minute, mi, n = Minute
23second, ss, s = Second
24millisecond, ms = Millisecond
25date	Required. The date to use
26
27Example:
28Return a specified part of a date:
29
30SELECT DATENAME(yy, '2017/08/25') AS DatePartString;
31Example
32Return a specified part of a date:
33
34SELECT DATENAME(month, '2017/08/25') AS DatePartString;
35Example
36Return a specified part of a date:
37
38SELECT DATENAME(hour, '2017/08/25 08:36') AS DatePartString;
39Example
40Return a specified part of a date:
41
42SELECT DATENAME(minute, '2017/08/25 08:36') AS DatePartString;