Use this: from datetime import datetime instead of Import datetime
# import datetime module import datetime start_date = "2022-05-06" # convert into datetime object and print print(datetime.datetime.strptime(start_date, "%Y-%m-%d"))