Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 93BD7632D26 for ; Mon, 23 Nov 2009 18:22:37 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 17798-06 for ; Mon, 23 Nov 2009 22:22:21 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sd.tpf.co.jp (sd.tpf.co.jp [210.161.239.34]) by mail.postgresql.org (Postfix) with SMTP id 32C01633180 for ; Mon, 23 Nov 2009 18:22:25 -0400 (AST) Received: (qmail 11818 invoked by uid 512); 23 Nov 2009 22:22:22 -0000 X-Authentication: inoue was authenticated by sd.tpf.co.jp at 23 Nov 2009 22:22:22 -0000 Received: from unknown (HELO ?192.168.24.53?) (210.148.129.222) by sd.tpf.co.jp with SMTP; 23 Nov 2009 22:22:22 -0000 Message-ID: <4B0B0B17.2000702@tpf.co.jp> Date: Tue, 24 Nov 2009 07:22:15 +0900 From: Hiroshi Inoue User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; ja; rv:1.8.1.23) Gecko/20090812 Thunderbird/2.0.0.23 Mnenhy/0.7.6.0 MIME-Version: 1.0 To: Josh T CC: pgsql-odbc@postgresql.org Subject: Re: VBA ADO Command Date Parameter Not Working References: <4B0AAE9D.9030201@rochester.rr.com> In-Reply-To: <4B0AAE9D.9030201@rochester.rr.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.965 tagged_above=-10 required=5 tests=AWL=0.635, BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 200911/68 X-Sequence-Number: 10117 Josh T wrote: > Hello, > > I'm using the PSQL-ODBC driver from Excel 2002 VBA with a ADO Command > object. What is the correct way to pass a date into a parameter so it > gets into the database correctly? - everything I've tried results in > 1900-05-07 added to the DB instead of the correct date. I also get > 1900-05-07 in the DB if I leave the date empty. I've simplified my code > into the following test case - I've had no problems with other data > types. I've already tried changing adDBDate, passing Date objects or > strings. > > Thanks, > Josh > > Sub TestDateInsert() > Dim conn As ADODB.Connection > Dim cmd As ADODB.Command > > Set conn = New ADODB.Connection > conn.Open "DSN=PRHTest" > > Set cmd = New ADODB.Command > cmd.ActiveConnection = conn > cmd.CommandType = adCmdText > cmd.CommandText = "INSERT INTO test_table (test_date) VALUES (?);" > cmd.Parameters.Append cmd.CreateParameter("@test_date", adDBDate, > adParamInput, , #11/23/2009#) > cmd.Execute , adExecuteNoRecords It seemd 2 commas are needed, i.e. cmd.Execute ,, adExecuteNoRecords regards, Hiroshi Inoue > Set cmd = Nothing > conn.Close > Set conn = Nothing > > End Sub > > Database Table definition: > > CREATE TABLE test_table ( > test_date date NOT NULL > ); >