How can I get a date that may not contain the month or the day?
Right now I only know how to break the date
date_n= '2022-12'
match_year = re.search(r'(?P<year_only>(?P<year>\d+))', date_n)
match_month = re.search(r'(?P<whole_date>(?P<year>\d+)-(?P<month>\d+))', date_n)
match_day = re.search(r'(?P<whole_date>(?P<year>\d+)-(?P<month>\d+)-(?P<day>\d+))', date_n)
year = match_year.group('year_only')
month = match_month.group('month')
day = match_day.group('day')
Try and Except does not work.