Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Prodentim Probiotics Specially Designed For The Health Of Your Teeth And Gums

Instant Grammar Checker - Correct all grammar errors and enhance your writing

Teach Your Child To Read

Powerful WordPress hosting for WordPress professionals

Disclosure: My content contains affiliate links.

31,111 questions

40,781 answers

573 users

How to add N days to a date in Python

2 Answers

0 votes
import datetime
from datetime import date, timedelta

d = datetime.datetime(2017, 11, 2, 19, 50, 12)

n = 4

days_ago = d + timedelta(days=n)

print(days_ago.year, "-", days_ago.month, "-", days_ago.day, sep='')


'''
run:

2017-11-6

'''

 





answered Nov 8, 2017 by avibootz
0 votes
import datetime
from datetime import date, timedelta

d = datetime.datetime(2017, 11, 9)

n = 4

days_ago = d + timedelta(days=n)

print(days_ago.year, "-", days_ago.month, "-", days_ago.day, sep='')


'''
run:

2017-11-13

'''

 





answered Nov 8, 2017 by avibootz

Related questions

1 answer 82 views
3 answers 102 views
102 views asked Apr 22, 2021 by avibootz
1 answer 42 views
42 views asked Jun 11, 2022 by avibootz
1 answer 48 views
48 views asked May 11, 2022 by avibootz
1 answer 59 views
...