pg.ddx.io  pgsql-odbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Josh T <mortonjt@rochester.rr.com>
To: Richard Broersma <richard.broersma@gmail.com>
Cc: pgsql-odbc@postgresql.org
Subject: Re: VBA ADO Command Date Parameter Not Working
Date: Mon, 23 Nov 2009 12:24:30 -0500
Message-ID: <4B0AC54E.2050005@rochester.rr.com> (raw)
In-Reply-To: <396486430911230855n6f283472t90c04e02615c075f@mail.gmail.com>
References: <4B0AAE9D.9030201@rochester.rr.com>
	<396486430911230855n6f283472t90c04e02615c075f@mail.gmail.com>

Richard Broersma wrote:
> on Mon, Nov 23, 2009 at 7:47 AM, Josh T <mortonjt@rochester.rr.com> wrote:
>>  What is the correct way to pass a date into a parameter so it gets
>> into the database correctly?
> 
> http://www.postgresql.org/docs/8.4/interactive/datetime-appendix.html
> 
> This is how Postgresql accepts dates by default.  There is a way to change this:
> 
> http://www.postgresql.org/docs/8.4/interactive/datatype-datetime.html#DATATYPE-DATETIME-INPUT
> http://www.postgresql.org/docs/8.4/interactive/runtime-config-client.html#GUC-DATESTYLE
> 
>> [5.750]conn=03044168, query='INSERT INTO test_table (test_date) VALUES
>> ('1900-05-07'::date);'
> 
> It looks like the ODBC driver is make the conversion here.
> Rather than passing the date in with the #...#.  Could you pass it in
> as a string?
> 


Thanks, but trying as string gives me the same result

cmd.Parameters.Append cmd.CreateParameter("@test_date", adDBDate, 
adParamInput, 4, "2009-11-23")
-> results in 1900-05-07 in the DB

I also get the same result in I leave the value out entirely

cmd.Parameters.Append cmd.CreateParameter("@test_date", adDBDate, 
adParamInput)
-> also results in 1900-05-07 in the DB

Trying a string this way doesn't work at all

cmd.Parameters.Append cmd.CreateParameter("@test_date", adVarChar, 
adParamInput, Len("2009-11-23"), "2009-11-23")
-> throws an error on cmd.Execute -- ERROR: invalid input syntax for 
type date: "128"; Error while executing the query

Thanks,
Josh



view thread (7+ messages)  latest in thread

Message-ID: <4B0AC54E.2050005@rochester.rr.com>
Permalink:  ../4B0AC54E.2050005@rochester.rr.com/
Also on:    postgresql.org/message-id/4B0AC54E.2050005@rochester.rr.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-odbc@postgresql.org
  Cc: mortonjt@rochester.rr.com, richard.broersma@gmail.com
  Subject: Re: VBA ADO Command Date Parameter Not Working
  In-Reply-To: <4B0AC54E.2050005@rochester.rr.com>
  References: <4B0AAE9D.9030201@rochester.rr.com> <396486430911230855n6f283472t90c04e02615c075f@mail.gmail.com> <4B0AC54E.2050005@rochester.rr.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox