[DB-SIG] Syntax for dates/times in prepared statements
Mon, 26 Jul 1999 19:42:03 GMT
On Mon, 26 Jul 1999 11:57:00 -0400 (EDT), you wrote:
>But a syntax error, you say. Is it possible that "when" is a reserved word
>in Sybase? If so, you may be able to circumvent this with a literal column
>> cursor.execute("""INSERT INTO analysis
>> (id, "when", what, howmuch)
>> VALUES (?,?,?,?)""", (id,when,what,howmuch))
Bingo! My first attempt called it 'Date', which I ard realised was
pretty stupid. My second try was "When", which is not listed anywhere
in their language reference, but still reserved - they have a
"whenever" which might explain it. Double quotes or a totally
different name fix it.
For the record, DateTime objects work fine in all positions, and can
go down to 0.01 second resolution in a Sybase TIMESTAMP field. In a
DATE field they get truncated to the nearest day, as expected.
The test output is handy, too - though I won't bombard M-A with all
300k now it works.
Thanks very much, everyone!