From: Jim Weirich Date: 2002-10-20T12:33:02+09:00 Subject: Re: Date handling with DBI On Thu, 2002-10-17 at 03:54, Gavin Sinclair wrote: > Rubyists, > > Given a table in a database defined by the following: > > create table test ( test DATE ); > > how can I insert the current time using Ruby/DBI? Given a DBI::DatabaseHandler > "dbh" I'd expect that you can do the following: > > dbh.do "insert into test values (#{Time.now})" This worked for me (using the PostgreSQL driver) .... db.do("insert into test values(?)", Time.now) IIRC, each individual driver handles conversions to its own native data types, so your driver might not handle that directly, If so, then you can try ... db.do("insert into test values(?)", DBI::Date.new(Time.now)) -- -- Jim Weirich jweirich@one.net http://w3.one.net/~jweirich --------------------------------------------------------------------- "Beware of bugs in the above code; I have only proved it correct, not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)