Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Python3 date calulation

FreQUENCY
 Share

How can i calculate the next day in python? The current date is easy to be calculated with datetime module. But i want the user to enter the date,not to parse the system date. Any ideas?

Link to comment
Share on other sites

Link to post
Share on other sites

What do you mean "Calculate the next day"? Do you mean getting the number of days between two dates or what?

 

Fan Comparisons          F@H          PCPartPicker         Analysis of Market Trends (Coming soon? Never? Who knows!)

Designing a mITX case. Working on aluminum prototypes.

Open for intern / part-time. Good at maths, CAD and airflow stuff. Dabbled with Python.

Please fill out this form! It helps a ton! https://linustechtips.com/main/topic/841400-the-poll-to-end-all-polls-poll/

Link to comment
Share on other sites

Link to post
Share on other sites


from datetime import datetime.
from datetime import timedelta.
#Add 1 day.
print datetime.now() +timedelta(days=1)

                     ¸„»°'´¸„»°'´ Vorticalbox `'°«„¸`'°«„¸
`'°«„¸¸„»°'´¸„»°'´`'°«„¸Scientia Potentia est  ¸„»°'´`'°«„¸`'°«„¸¸„»°'´

Link to comment
Share on other sites

Link to post
Share on other sites

Done!


import time
from datetime import date, timedelta
INPUTED_DATE=input()

while INPUTED_DATE!="END" and INPUTED_DATE!="end":
  new_date=INPUTED_DATE[:2]+INPUTED_DATE[3:5]+INPUTED_DATE[6:]
  #print (new_date)
  t=time.strptime(new_date,'%d%m%Y')
  formated_date=date(t.tm_year,t.tm_mon,t.tm_mday)+timedelta(1)
  print (formated_date.strftime('%d-%m-%Y'))
  INPUTED_DATE=input()
  
  
  
  

 

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share


×