Date strftime('%d%m%y') date to be of yesterday

baboucarr sanneh sanneh27 at hotmail.com
Thu Oct 22 06:33:00 EDT 2009



Hi tim,

well i tried what your script but i do have an error
>>> import datetime
>>> yesterday = datetime.date.today () - datetime.timedelta (days=1)
>>> print yesterday.strftime ("%d%m%y")
SyntaxError: invalid syntax (<pyshell#2>, line 1)

when i jus check the variable i.e yesterday i do get the out put but its in a different format
datetime.date(2009, 10, 21)
it seems like the conversion that is where the error is coming form 

I want it to be like 211009 

Thank you

$LIM $H at DY



> Date: Thu, 22 Oct 2009 11:14:46 +0100
> From: mail at timgolden.me.uk
> CC: python-list at python.org
> Subject: Re: Date strftime('%d%m%y') date to be of yesterday
> 
> baboucarr sanneh wrote:
> > 
> > Hi all
> > 
> > I want to output the date of the with this format strftime('%d%m%y') but the date ie '%d' should be the date of yesterday
> > eg
> > 
> > import time
> > strftime('%d%m%y') # something like minus a day..
> > Thank you..am a newbie to python
> 
> 
> <code>
> import datetime
> yesterday = datetime.date.today () - datetime.timedelta (days=1)
> print yesterday.strftime ("%d%m%y")
> </code>
> 
> TJG
> -- 
> http://mail.python.org/mailman/listinfo/python-list
 		 	   		  
_________________________________________________________________
Windows Live: Keep your friends up to date with what you do online.
http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_1:092010
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20091022/35a1473c/attachment.html>


More information about the Python-list mailing list