'Read excel dates and convert them to individual strings [duplicate]

I recently started using python. I have a series of dates in excel

01-05-2021

02-05-2021

. .

29-05-2021

Now, I want to load this column and convert it into individual strings based on rows. So i can extract the day, month and year separately for each dates

Can someone help me how to do that??



Solution 1:[1]

from datetime import datetime

str_time = 01-05-2021 time_convert = datetime.strptime(str_time, '%d-%m-%Y')

print (time_convert, time_convert.day, time_convert.month, time_convert.year)

in your case, make the convert in looping for each data you got from the excel file

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Henro Sutrisno Tanjung