How to change Date Formats in Excel using Python | From any Format to any other

preview_player
Показать описание
Hi,
Sometimes we need certain formats in Excel which are not possible to do it without outside help, such as Python. In fact, I don't know any other tools such as Python to achieve this task.
Openpyxl is a library which is generally used to perform such tasks. This video presents the process to convert a date format 'YYYY/MM/DD' to 'DD-MM-YYYY'.
Thanks!
Рекомендации по теме
Комментарии
Автор

The only video (that I could find so far ) that practically shows to read and write Excel dates with openpyxl ! Thanks a lot !

vishalparkar
Автор

Thanks!!! this really helped me in order to change any date format without taking an exhausting excel tutorial..

juandiegoangeleshernandez
Автор

Hi,

Is it possible to split 20220930 into 30-09-2022 format?

nikhilavemuri
Автор

AttributeError: 'datetime.datetime' object has no attribute 'split'

what ever range I use it says the same error

Aida-sf
Автор

As you took YYYY-dd--mm as input date format. but what is input date format is different for different excel files?

hemantkumbhar
Автор

Nice explanation . I have similar relatime scenario. details below.



I am attempting to convert dynamically all date columns to YYYY-MM-DD format using dataframe that come from read_csv.



input Dataframe

empno, ename, hiredate, report_date, end_date
1, sreenu, 17-Jun-2021, 18/06/2021, May-22




output



empno, ename, hiredate, report_date, end_date
1, sreenu, 2021-06-17, 2021-06-18, 2022-05-31




1. if date is MMM-YY or MM-YYYY(May-22 or 05-2022) (then last day of the month(2022-05-31)
2. other than point 1 then it should be YYYY-MM-DD

Now i want create a method/function to identify all date datatype columns in dataframe then convert to YYYY-MM-DD format/user expected format.

kottakaburlu