datepart()

Scalar. Returns an integer representing a portion of a date.

Syntax

datepart ( portion, datevalue )

Parameters

portion
One of the following strings:
  • The year, if the string is yy or yyyy.
  • The month, if the string is mm or m.
  • The day of the year, if the string is dy or y.
  • The day of the month, if the string is dd or d.
  • The day of the week, if the string is dw.
  • The hour, if the string is hh.
  • The minute, if the string is mi or n.
  • The second, if the string is ss or s.
datevalue

A date or bigdatetime.

Usage

Returns an integer representing a portion of a date. The portions that the function can return are the year, the month, the day of the year, the day of the month, the day of the week, the hour, the minute, or the second. The function takes a string as the portion argument, and a date or bigdatetime for the datevalue argument. The function returns an integer.

Example

datepart ( 'ss', undate ('2010-03-03 12:34:34')) returns 34.