SQLite Forum

How do I access urls in a sqlite database using timedelta?
Login
I have an sqlite database that contains a timestamp column and a url column. I'm trying to select the urls using timestamps and timedelta with timedelta set to 1 hour. I have tried to use "past_time" to select them but it's not working for me for some reason. I have also tried "BETWEEN" to isolate the times but it doesn't work either. It's not giving me any errors but just returns an empty list every time.

~~~~~
timenow = datetime.now()
delta = timedelta(minutes=0)
delta2 = timedelta(minutes=5)
prevtime = timenow - delta
prevtime2 = timenow - delta2

past_time = prevtime.strftime('%Y-%m-%d %H:%M:%S')
past_time2 = prevtime2.strftime('%Y-%m-%d %H:%M:%S')

conn = sqlite3.connect('ddother.db')
c = conn.cursor()
c.execute('SELECT adUrl FROM donedeal_listings WHERE timestamp BETWEEN "past_time2" AND "past_time"')

all_urls = c.fetchall()

print(all_urls)

conn.commit()
~~~~~