This Python DateTime tutorial will teach you how to get year and month from DateTime. You can find the year and month from DateTime using the following code:
# Import the datetime module import datetime # Get the current date and time date_time = datetime.datetime.now() # Get the year year = date_time.year # Get the month month = date_time.month # Display the year and month print("Year:", str(year)) print("Month:", str(month))