I am facing a date format converting issue now. There will be some date format data passing in like: Jul 2022 or some times 11/2022 or Sept 2022 or sometimes 11/11/2021. I can't control what date format will be passing in. But I have to return exactly date if dd/mm/yyyy is passing in. For all other format that missing date like mm/yyyy, I have to return end of month date format like: if Sept 2022 passes in, I will return 09/30/2022.
Currently, my code will be like this. parse will return a date not that randomly. But it will add today's date to it like below. Is there a way to achieve my goal easily? from dateutil.parser import parse parse(columns[2])
parser.parse("09/2022").date() datetime.date(2022, 9, 23)