1

I have this script what gets me the last datetime from a database table:

import MySQLdb
import datetime as dt

database = MySQLdb.connect (host="localhost", user = "root", passwd = "1234", db = "meh")
cursor = database.cursor()
query_timestamp = "SELECT refuelling_date FROM `emil_touch_fuellings` ORDER BY refuelling_date DESC LIMIT 1"
cursor.execute(query_timestamp)
dblastentrytime = cursor.fetchone()
for i in dblastentrytime:
    current=i

startdate= current.strftime('%d/%m/%Y')
enddate = dt.datetime.today().strftime("%d/%m/%Y")
cursor.close()
print startdate

This will output 05/10/2016, but I want to get +1 to day to get 06/10/2016. Each time I run my script I want to get my startdate var with a +1 day on date I got from my db. I'm using python.

Rommel
  • 235
  • 2
  • 10
  • 4
    This post should answer your question: http://stackoverflow.com/questions/6871016/adding-5-days-to-a-date-in-python – sweetdude Oct 06 '16 at 17:11

1 Answers1

0

for adding one day to a date use:

import datetime

date = datetime.datetime(2012,9,23,12,4,5)
date += datetime.timedelta(days=1)

now day is 24

Amin Etesamian
  • 3,363
  • 5
  • 27
  • 50