getyear()

Returns the year part of the datetime argument.

Syntax

getyear(date)

Parameters

Name Type Required Description
date datetime The date for which to get the year.

Returns

The year that contains the given date.

Example

print year = getyear(datetime(2015-10-12))
year
2015