9951 explained code solutions for 126 technologies


python-pandasGet current year and month


from datetime import datetime

currentYearMonth = "{month}/{year}".format(
  month = datetime.now().month,
  year = datetime.now().year
)ctrl + c
from datetime import datetime

import datetime utility to operate with time

datetime.now()

returns current date object

.year

attribute returns year

.month

attribute returns month

"{month}/{year}".format

format resulting month/year string in a given way

currentYearMonth

will contain final formatted month/year string