datetime_part()

This article describes datetime_part().

Extracts the requested date part as an integer value.

Syntax

datetime_part(part,datetime)

Parameters

NameTypeRequiredDescription
partstring✔️Measurement of time to extract from date. See possible values.
datedatetime✔️The full date from which to extract part.

Possible values of part

  • Year
  • Quarter
  • Month
  • week_of_year
  • Day
  • DayOfYear
  • Hour
  • Minute
  • Second
  • Millisecond
  • Microsecond
  • Nanosecond

Returns

An integer representing the extracted part.

Example

let dt = datetime(2017-10-30 01:02:03.7654321); 
print 
year = datetime_part("year", dt),
quarter = datetime_part("quarter", dt),
month = datetime_part("month", dt),
weekOfYear = datetime_part("week_of_year", dt),
day = datetime_part("day", dt),
dayOfYear = datetime_part("dayOfYear", dt),
hour = datetime_part("hour", dt),
minute = datetime_part("minute", dt),
second = datetime_part("second", dt),
millisecond = datetime_part("millisecond", dt),
microsecond = datetime_part("microsecond", dt),
nanosecond = datetime_part("nanosecond", dt)

Output

yearquartermonthweekOfYeardaydayOfYearhourminutesecondmillisecondmicrosecondnanosecond
20174104430303123765765432765432100