import datetime filedate = datetime.fromtimestamp(os.path.getmtime(rootpath + "/" + fName)) #filedate = datetime.date(2014, 1, 27) today = datetime.now maxdate = datetime.date(2011, 7, 2) #Only do work if the number of days since the last change is less than the number of days since a 'too long ago' date. if (filedate - today).days < (filedate - maxdate).days: print('Work on this file') else: print('Do nothing')
>>> import datetime>>> test = datetime.date(2011, 7, 2)>>> print test2011-07-02>>> str(test)'2011-07-02'>>>
import datetime filedate = datetime.date(2014, 1, 27) comparedate = datetime.date(2013, 12, 31) if (filedate - comparedate).days > 0: print('Work on this file') else: print('Do nothing')
>>> Work on this file
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.