Code looks great. You're missing one edge case, if the user enters 12-12-2024
the result is an empty year which shouldn't be the case. It should give out an error saying the date shouldn't be in the future.
Marked as helpful
@cwatso
Posted
@rvarunr5 Good catch! I have updated the code to account for this and any other future dates within current year.