import datetime mydate = datetime.datetime.strptime('2017-12-01', '%Y-%m-%d') print mydate.month >> 12