DATEPART (interval, date)


Returns an integer that represents the requested portion of a given date.


interval A String portion of a date that can be:

— yyyy = year
— m = month
— d = day of the month specified in date
— dy = day of the year specified in date
— ww = week of the year
— h = hour
— n = minute
— s = second
date A date and time as a DateTime or String.


An Integer32 that represents the requested portion of the date.


DATEPART does not support the day of the week, such as Monday or Tuesday.

Day of year (dy) returns an integer from 1 to 366 corresponding to the sequential day of the year.

DateTime functions use the local date and time functions. For example:

The value returned by week (ww) depends on a number of factors, including the day of the week for January 1 of the specified year. When determining DATEPART, the first day of the week is always considered to be a Sunday.


To return the month in a source field called PurchaseDate, where the value of the source field = 6/5/2013 and the locale is US:

DATEPART ("m", MyEntity.PurchaseDate)

Returns: 6

Related Topics

DateTime Functions