How get year, month, day from month ?

How to replace year, month, day in date object and get new date object ?

from datetime import dated = date(year=2017, month=4, day=3)# replace year with 2015old_date = d.replace(year=2015)print(old_date)# Output: 2015-04-03print(d)# Output: 2017-04-03# in the same way we can replace month, day