[program-l] Python: how do I remove the time component from a date?

  • From: <pranav@xxxxxxxxxxxxxxxxx>
  • To: <program-l@xxxxxxxxxxxxx>
  • Date: Mon, 3 Jan 2022 21:46:34 +0530

Hi all,

I have the following code which should give me only date but the time
component is still there.

start_date=datetime.date.today().strftime('%Y') + "/01/01"
start_date=parser.parse(start_date)


end_date=datetime.date.today().strftime('%Y/%m/%d')
end_date=parser.parse(end_date)
print(start_date)
print(end_date)
sys.exit()

The output of the above code is:
2022-01-01 00:00:00
2022-01-03 00:00:00

The time component is still there.
Pranav

** To leave the list, click on the immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=unsubscribe]
** If this link doesn't work then send a message to:
** program-l-request@xxxxxxxxxxxxx
** and in the Subject line type
** unsubscribe
** For other list commands such as vacation mode, click on the
** immediately-following link:-
** [mailto:program-l-request@xxxxxxxxxxxxx?subject=faq]
** or send a message, to
** program-l-request@xxxxxxxxxxxxx with the Subject:- faq

Other related posts: