Why I'm getting the date of yesterday

Simon Brunning simon at brunningonline.net
Tue Jan 20 14:20:20 CET 2009


2009/1/20 Hussein B <hubaghdadi at gmail.com>:
> Hey,
> I'm trying to get the get the date before today, I tried this:
> d = datetime.now() - timedelta(days = -1)
> But I got the date of tomorrow.

That's because you are taking away a negative value. This is like doing:

>>> 0 - (-1)
1

-- 
Cheers,
Simon B.



More information about the Python-list mailing list