Why I'm getting the date of yesterday

2009-01-20 Thread Hussein B
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.
when I tried:
d = datetime.now() + timedelta(days = -1)
I got the date of yesterday.
Would you please explain to me why I got the date of yesterday when I
added the both objects?
Thanks.

--
http://mail.python.org/mailman/listinfo/python-list


Re: Why I'm getting the date of yesterday

2009-01-20 Thread Simon Brunning
2009/1/20 Hussein B hubaghd...@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.
--
http://mail.python.org/mailman/listinfo/python-list