Skip to main content

DATEPART() Function

Definition The DATEPART() function returns a specific part of a date.  This function returns the result as an integer value.    Syntax DATEPART(interval,date) where interval is required and it is the

Updated over 2 weeks ago

Definition

The DATEPART() function returns a specific part of a date. This function returns the result as an integer value.

Syntax

DATEPART(interval,date)

where interval is required and it is the part of return. This can be one of the following values:

  • year, yyyy, yy = Year

  • quarter, qq, q = Quarter

  • month, mm, m = month

  • dayofyear, dy, y = Day of the year

  • day, dd, d = Day of the month

  • week, ww, wk = Week

  • weekday, dw, w = Weekday

  • hour, hh = hour

  • minute, mi, n = Minute

  • second, ss, s = Second

  • millisecond, ms = Millisecond

And date is required and is the date to use.

Example(s)

See how DATEPART can be used to

Did this answer your question?