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

  • From: <pranav@xxxxxxxxxxxxxxxxx>
  • To: <program-l@xxxxxxxxxxxxx>
  • Date: Tue, 4 Jan 2022 05:36:59 +0530

Travis,

You were right. The following code works.

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


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

I had to add a .date to the parser method for it to yield the date.

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: