TransWikia.com

Add a year to current date

Stack Overflow Asked by user13788524 on November 12, 2021

from datetime import *

date = date.today()

Printing date gives me "2020-07-21"

How may I go about adding a year to that date?

2 Answers

Try:

import  datetime as dt 
d = date.today()
dt.date(d.year + 1,d.month, d.day)

Answered by ipj on November 12, 2021

from datetime import *
from dateutil.relativedelta import relativedelta

date = date.today()
newDate = date + relativedelta(years=1)

Answered by Daniel E on November 12, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP