Why I'm getting the date of yesterday

H

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.
 
S

Simon Brunning

2009/1/20 Hussein B said:
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:
1
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top