Checking date against date range in Python

Posted by Flowpoke on Stack Overflow See other posts from Stack Overflow or by Flowpoke
Published on 2011-01-14T20:29:30Z Indexed on 2011/01/15 23:53 UTC
Read the original article Hit count: 247

Filed under:
|
|
|
|

I have a date variable: 2011-01-15 and I would like to get a boolean back if said date is within 3 days from TODAY. Im not quite sure how to construct this in Python. Im only dealing with date, not datetime.

My working example is a "grace period". A user logs into my site and if the grace period is within 3 days of today, additional scripts, etc. are omitted for that user.

I know you can do some fancy/complex things in Python's date module(s) but Im not sure where to look.

© Stack Overflow or respective owner

Related posts about python

Related posts about datetime