C M <[EMAIL PROTECTED]> wrote:
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?

I don't know Python well enough, but the SQL statement you want would look like this:

SELECT string FROM test WHERE d >= date('now', ? || ' days');

|| is the string concatenation operator in SQL.

Igor Tandetnik

-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to