Detlef Jockheck wrote:
Hi,

I have a date-string given in format "dd.mm.yyyy". Now I would like to add 100 days. How can this be solved in python?

import datetime

def add100days(datestring):
    day, month, year = [int(x) for x in datestring.split('.')]
    date0 = datetime.date(year, month, day)
    date1 = date0 + datetime.timedelta(days=100)
    newdatestring = '%.2d.%.2d.%.4d' % (date1.day, date1.month,
        date1.year)
    return newdatestring


You may want to do the details differently, but datetime is the module that you want to use.


--
Robert Kern
[EMAIL PROTECTED]

"In the fields of hell where the grass grows high
 Are the graves of dreams allowed to die."
  -- Richard Harter
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to