datetime get year code example
Example 1: month from datetime pandas
#Exctract month and create a dedicated column df["Month"] from a
#column in datetime format df["Date"]
df['Month'] = pd.DatetimeIndex(df['Date']).month
Example 2: python date get day
import datetime
dt = datetime.datetime.today()
year = dt.year
month = dt.month
day = dt.day
Example 3: date.month date time
import datetime
dt = datetime.datetime.today()
print dt.year
# Output: 2016
print dt.month
# Output: 8
print dt.day
# Output: 22