Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a script that I want to have an if statement check if a file falls between several specified date periods as it searches directories. I have been able to get the time in %Y-%m-%d format for the file, but I can't seem to be able to specify a date range for python to go through. Any ideas/help?

Here's what I have so far

for name in files:
    f = os.path.join(root, name)
    dt = os.path.getmtime(f)
    nwdt = time.gmtime(dt)
    ndt = time.strftime('%Y-%m-%d', nwdt)
share|improve this question

closed as off-topic by Karan, Ignacio Vazquez-Abrams, gronostaj, grawity, Louis Jul 2 '13 at 0:12

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions about software development are off-topic here, but can be asked on Stack Overflow." – Karan, Ignacio Vazquez-Abrams, gronostaj, grawity, Louis
If this question can be reworded to fit the rules in the help center, please edit the question.

    
This is off-topic, and should be on Stack Overflow instead of Super User –  ernie Jul 1 '13 at 21:48

1 Answer 1

if datetime.datetime(...) < datetime.datetime.utcfromtimestamp(dt) < datetime.datetime(...):
   ...
share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.