getmonth()

Get the month number from a datetime.

Another alias: monthofyear()

Syntax

getmonth(date)

Parameters

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

Returns

An integer between 1-12 representing the month that contains the given date.

Example

print month = getmonth(datetime(2015-10-12))
month
10