Values for the datepart parameter. : DATEPART « Date Functions « SQL Server / T-SQL Tutorial






This function returns an integer value for the part of a date specified in the date part selection.
The syntax for DATEPART is:

DATEPART ( datepart , date )

The second parameter, date, designates the date for which the integer value is calculated.


datepart (Full Name)       Abbreviation             Values

year                       Yy                       1753-9999

quarter                    Qq                       1-4

month                      Mm                       1-12

dayofyear                  Dy                       1-366

day                        Dd                       1-31

week                       Wk                       1-53

weekday                    Dw                       1-7 (Sunday-Saturday)

hour                       Hh                       0-23

minute                     Mi                       0-59

second                     Ss                       0-59

millisecond                Ms                       0-999








10.8.DATEPART
10.8.1.DATEPART returns part of a date as an integer value.
10.8.2.Values for the datepart parameter.
10.8.3.WHERE DATEPART(WEEKDAY, pubdate) = 3
10.8.4.where DATEPART(DAY, pubdate) BETWEEN 8 AND 14
10.8.5.where DATEDIFF(WEEK, pubdate, GETDATE()) <= 48
10.8.6.DATEPART Function returns the integer value of the datepart specified: DATEPART(datepart,date)
10.8.7.select DATEPART(day, '2002-09-30 11:35:00')
10.8.8.select DATEPART(month, '2002-09-30 11:35:00')
10.8.9.select DATEPART(year, '2002-09-30 11:35:00')
10.8.10.select DATEPART(hour, '2002-09-30 11:35:00')
10.8.11.select DATEPART(minute, '2002-09-30 11:35:00')
10.8.12.select DATEPART(second, '2002-09-30 11:35:00')
10.8.13.select DATEPART(quarter, '2002-09-30 11:35:00')
10.8.14.select DATEPART(dayofyear, '2002-09-30 11:35:00')
10.8.15.select DATEPART(week, '2002-09-30 11:35:00')
10.8.16.select DATEPART(weekday, '2002-09-30 11:35:00')
10.8.17.select DATEPART(m,'2002-09-30')
10.8.18.SELECT DATEPART(dd, '7/5/99')
10.8.19.SELECT DATEPART(dd, '7/5/00')
10.8.20.IF DATEDIFF(dd, '7/5/99','7/5/00') = 0
10.8.21.(DATEPART(mm, @date1) = DATEPART(mm, @date2))
10.8.22.(DATEPART(dd, @date1) = DATEPART(dd, @date2))
10.8.23.(DATEPART(yy, @date1) = DATEPART(yy, @date2)
10.8.24.Identifying Weekday
10.8.25.Grouping by the Week by using datepart function