Re: Problem with DATE - Mailing list pgsql-jdbc

From Vinayak
Subject Re: Problem with DATE
Date
Msg-id 1421735828048-5834706.post@n5.nabble.com
Whole thread Raw
In response to Re: Problem with DATE  (dmp <danap@ttc-cmc.net>)
List 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.


pgsql-jdbc by date:

Previous
From: rapidtransit440@aol.com
Date:
Subject: Re: problem with pgjdbc prepared statements and new jsonb exists operator (?)
Next
From: Peter Mortier
Date:
Subject: Re: problem with pgjdbc prepared statements and new jsonb exists operator (?)