hi C M,
I'm by no means an expert but what I do in similar cases is: I prepare
the variables beforehand - actually I prepare the whole SQL statement
beforehand and do normally not use ?. except by executemany.
date=date("now","+1 day")
sqlcu.execute ("SELECT string FROM test WHERE d >=?",(date,) )
or something like that should also work:
sqlcu.execute ("SELECT string FROM test WHERE d >=?", (date("now", "+1
day"),) )
I actually use never the date but convert everything to utc timestamps
in an extra column.
regards W.Braun
C M wrote:
I'm new to SQLite and can't figure out the right way to write this. I want
to select a range of dates, let's say anything beyond tomorrow So in my
table called test I want to select the column called string based on the
date being tomorrow or later...
This statement (from the sql wiki about dates) in my Python code works:
cur.execute('SELECT string FROM test WHERE d >= date("now","+1 day")')
However, I'd like to make it flexible, so that a user can put in an amount
of days forward or backward and the query will use that--basically I want
the user to be able to select the date range over the data in the table. I
tried something like:
amount = "1" #just to try it, later this will refer to a user-chosen
variable
cur.execute ('SELECT string FROM test WHERE d >= date("now", "+",?,"
day")',amount)
But of course that's not right and it doesn't work. What is the right
syntax in this case to use the ? to stand for the 1 in the original "+1 day"
portion?
Or am I barking up the wrong tree with this approach? Ultimately I want to
make it totally generalizable, so that users can select whatever range of
dates they want, and so I thought I needed a way to sub in the variable of
#of days--just not sure how.
Any help is appreciated.
-
To unsubscribe, send email to [EMAIL PROTECTED]
-