I'm trying to get the difference in years between two dates (in string) 'start date' and 'end date' from a list, but I noticed the list of dates are not in the right format. After trying to convert to the same format, the output keeps changing the year to 2021 which is wrong. Here is my code and output
start_date= ['18-Aug', '12-Aug', 'Nov-19', 'Oct-17', '19-Apr', 'Mar-15', '12-Jul', 'Jul-15', '13-May', '13-Oct']
for i in range(len(start_date)):
print(dateutil.parser.parse(start_date[i]).strftime("%y-%b"))
Output:
21-Aug
21-Aug
21-Nov
21-Oct
21-Apr
21-Mar
21-Jul
21-Jul
21-May
21-Oct
Expected output should be:
18-08
12-08
19-11
17-10
19-04
15-03
12-07
15-07
13-05
13-10