Use datetime module if you are on 2.3 or 2.4, otherwise you can do: today=time.time() yesterday=today-24*60*60 # 24 hours x 60 minutes x 60 seconds
Your problem is that time.localtime() converts to 9 value tuple (you can't subtract seconds from a tuple). You do the math on today and convert using time.localtime after. For future reference: Please post a copy of your traceback instead of just saying "<-- generates and error". It helps people to respond more quickly and accurately. -Larry Bates Simon Brunning wrote: > On 4/19/05, Ralph Hilton <[EMAIL PROTECTED]> wrote: > >>i'm a beginning python programmer. >> >>I want to get the date for yesterday >> >>nowTime = time.localtime(time.time()) >>print nowTime. >>oneDay = 60*60*24 # number seconds in a day >>yday = nowTime - oneDay # <-- generates an error >>print yday.strftime("%Y-%m-%d") > > > today = datetime.date.today() > previous_working = today - datetime.timedelta(days=1) > -- http://mail.python.org/mailman/listinfo/python-list