Re: Problem with DATE

From: Vinayak <vinpokale(at)gmail(dot)com>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Problem with DATE
Date: 2015-01-20 06:37:08
Message-ID: 1421735828048-5834706.post@n5.nabble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Hi,

ps = conn.prepareStatement("SELECT to_date(?,'yyyy-mm-dd')");
java.sql.Date sqlDate1 = new java.sql.Date(new java.util.Date().getTime());
ps.setDate(1, sqlDate1);
This works fine because here driver sent the DATE type instead of
UNSPECIFIED to the server.
we can also use the below solution for such problems:
ps = conn.prepareStatement("SELECT to_date(?,'yyyy-mm-dd')");
OR
ps = conn.prepareStatement("SELECT ?::date");
OR
ps = conn.prepareStatement("SELECT date(?)");

-----
Regards,
Vinayak,

--
View this message in context: http://postgresql.nabble.com/Problem-with-DATE-tp5833008p5834706.html
Sent from the PostgreSQL - jdbc mailing list archive at Nabble.com.

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Peter Mortier 2015-01-20 07:08:36 Re: problem with pgjdbc prepared statements and new jsonb exists operator (?)
Previous Message rapidtransit440 2015-01-19 23:25:29 Re: problem with pgjdbc prepared statements and new jsonb exists operator (?)