Skip to content
Open
Changes from 1 commit
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
Next Next commit
month_and_year.py
  • Loading branch information
YT116 committed Apr 22, 2025
commit 685f7698069805a24088e645b565ef4119d2c43a
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