WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions month_and_year.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
previous issue : prints only month at the moment because you have mentioned only %B to extrac the year we need to use %Y along with %B(i.e month)
"""

from datetime import datetime

date = "29-01-2025"

date_obj= datetime.strptime(date, "%d-%m-%Y")
print(date_obj.strftime("%B %Y"))


# mention that if you’re looping through dates from a CSV, then you just need to apply the format like:

# data_obj = datetime.strptime(date,"%d-%m-%Y")
# print(data_obj.strftime(%B %Y)) %B for month and %Y for year