--3MwIy2ne0vdjdPXF Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Oct 17, 2002 at 04:54:17PM +0900, 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})" > > That is, I expect the DBI library to convert a Time object into the database's > DATE data type. It appears that this is not the case. The above code causes > an error. > > It doesn't convert the String '2002-10-04 18:30:00' into a DATE either. > > For now, I am resorting to storing my date information as strings in the > database. Does anyone know about the logistics of database-independent data > handling? I use DBI with Mysql and prepared statements: stm = dbh.prepare("intert into test values (?)") stm.execute(Time.now) -billy. -- Meisterbohne Söælinger StraÝÆ 100 Tel: +49-731-399 499-0 eLungen 89077 Ulm Fax: +49-731-399 499-9 --3MwIy2ne0vdjdPXF Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.0 (GNU/Linux) iD8DBQE9rq7yfBriNoqItSYRAgbiAJ9T+ZuGK8bwTi39YF3DP24hSXcfVwCfYPcw ljccc+UKRSfEep/5r9mZsRE BD -----END PGP SIGNATURE----- --3MwIy2ne0vdjdPXF--