Oct-27-2022, 09:57 PM
another solution using built-in date methods:
import datetime def convert_date(orig): massaged_date = orig.replace("'", "/")[1:] return datetime.datetime.strftime(datetime.datetime.strptime(massaged_date, "%m/%d/%Y"), "%m/%d/%Y") def testit(): orig_date = "D4/7'2004" finaldate = f"D{convert_date(orig_date)}" print(f"{finaldate}") testit()results of test:
Output:D04/07/2004