Logic for if statement that executes code based on exception in Python
Question: I would like to run a script every five minutes in windows task scheduler. The
script reads a JSON web-service of service requests and writes specified
fields to an esri geodatabase.

For this process, there is a time stamp, with the information to query the
time per service request.

My question is how do I create the logic in this script to say **"Hey, I ran
successfully for 12:00PM-12:05:59PM, something happened for 12:06-12:11:59,
but I will run for 12:11-12:16:59, and since I am so nice I will grab data for
12:06-12:11."**

the logic that I have built into my code so far is;

    
    
    import datetime
    
    
    DateofDataCreation = 2015-02-17 16:53:25
    i = 5
    Start = datetime.datetime.now()
    now_minus_5 = Start - datetime.timedelta(minutes =i)
    
    
    if DateofDataCreation >= now_minus_5:
        WriteToDatabase
    else:
        print "No Current Data"
    


Answer: am not sure if I understand your question exactly. Based on what I think you
are asking, try this:

    
    
    import datetime
    
    #If you change the time to be after now() then it will print "WriteToDatabase" .
    #If the time is before then it will print "No Current "Data"
    DateofDataCreation = datetime.datetime(2015,2,17,16,53,25)
    
    i = 5
    
    Start = datetime.datetime.now()
    now_minus_5 = Start - datetime.timedelta(minutes =i)
    
    
    
    if DateofDataCreation >= now_minus_5:
    
         print("WriteToDatabase")
    else:
         print ("No Current Data")
    

