Hi Pranav,
Datetime.date.today().strftime("%Y/%m/%m")
Does return a string without the time for me when I tried it in the console.
I assume the problem is with whatever the parser method is doing.
-----Original Message-----
From: program-l-bounce@xxxxxxxxxxxxx <program-l-bounce@xxxxxxxxxxxxx> On
Behalf Of pranav@xxxxxxxxxxxxxxxxx
Sent: Monday, January 3, 2022 10:17 AM
To: program-l@xxxxxxxxxxxxx
Subject: [program-l] Python: how do I remove the time component from a date?
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
** 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