Re: Problem with DATE

Поиск
Список
Период
Сортировка
От Vinayak
Тема Re: Problem with DATE
Дата
Msg-id 1421735828048-5834706.post@n5.nabble.com
обсуждение исходный текст
Ответ на Re: Problem with DATE  (dmp <danap@ttc-cmc.net>)
Список 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 по дате отправления:

Предыдущее
От: rapidtransit440@aol.com
Дата:
Сообщение: Re: problem with pgjdbc prepared statements and new jsonb exists operator (?)
Следующее
От: Peter Mortier
Дата:
Сообщение: Re: problem with pgjdbc prepared statements and new jsonb exists operator (?)