The DatePart()
function retreives a part from a date. e.g. the year, the month or the minutes.
Syntax
DatePart(date, unit)
Returns
A number that is a part of a date. If the date is unknown then this function returns unknown.
Parameters
date
a date.unit
the [date unit][1] that is retreived fromdate
.
Examples
DatePart('2014-08-21T12:00:30', Year)
/* Returns 2014 */
DatePart('2014-08-21T12:00:30', Month)
/* Returns 8 */
DatePart('2014-08-21T12:00:30', Hour)
/* Returns 12 */
DatePart('2014-08-21T12:00:30', Minute)
/* Returns 0 */
DatePart(UnknownDateTime, Year)
/* unknown */