pg.ddx.io pgsql-jdbc@postgresql.org mailing list archive
help / color / mirror / Atom feedDate format problem with INSERT statement.
3+ messages / 3 participants
[nested] [flat]
* Date format problem with INSERT statement.
@ 2006-04-13 14:38 Olav Gjerde <olavgjerde@yahoo.no>
2006-04-13 14:51 ` Re: Date format problem with INSERT statement. Xavier Poinsard <xpoinsard@free.fr>
0 siblings, 1 reply; 3+ messages in thread
From: Olav Gjerde @ 2006-04-13 14:38 UTC (permalink / raw)
To: pgsql-jdbc
If I do an:
INSERT INTO wdata (date)
VALUES ('13.04.06');
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Date format problem with INSERT statement.
2006-04-13 14:38 Date format problem with INSERT statement. Olav Gjerde <olavgjerde@yahoo.no>
@ 2006-04-13 14:51 ` Xavier Poinsard <xpoinsard@free.fr>
0 siblings, 0 replies; 3+ messages in thread
From: Xavier Poinsard @ 2006-04-13 14:51 UTC (permalink / raw)
To: Olav Gjerde <olavgjerde@yahoo.no>; +Cc: pgsql-jdbc
You should consider using the jdbc escape format for dates {d
'yyyy-mm-dd'} =>
INSERT INTO wdata (date) VALUES ({d '2006-04-13');
see http://jdbc.postgresql.org/documentation/head/escapes-datetime.html
Olav Gjerde a écrit :
> If I do an:
>
> INSERT INTO wdata (date)
> VALUES ('13.04.06');
>
> From the Query Tool in PGAdmin it will insert the dd.mm.yy format
> correctly without problems.
>
>
> But when I do this in Java I get this error message
>
> SQLException: ERROR: date/time field value out of range: "13.04.06"
> SQLState: 22008
> VendorError: 0
>
> This is because it reads the date format as mm.dd.yy because when I
> insert with the value '12.04.06' it works perfect. I've changed the
> datestyle in my Database to European but it still doesn't work. Do the
> JDBC driver only insert dates in the US format?
>
> Olav
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Date format problem with INSERT statement.
@ 2006-04-13 15:46 Guy Rouillier <guyr@masergy.com>
0 siblings, 0 replies; 3+ messages in thread
From: Guy Rouillier @ 2006-04-13 15:46 UTC (permalink / raw)
To: pgsql-jdbc
Olav Gjerde wrote:
> But when I do this in Java I get this error message
>
> SQLException: ERROR: date/time field value out of range: "13.04.06"
> SQLState: 22008
> VendorError: 0
>
> This is because it reads the date format as mm.dd.yy because when I
> insert with the value '12.04.06' it works perfect. I've changed the
> datestyle in my Database to European but it still doesn't work. Do
> the JDBC driver only insert dates in the US format?
Consider using PreparedStatement. Then you can store your date value as
a java.sql.Date variable, and set the column value to that.
--
Guy Rouillier
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2006-04-13 15:46 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-04-13 14:38 Date format problem with INSERT statement. Olav Gjerde <olavgjerde@yahoo.no>
2006-04-13 14:51 ` Xavier Poinsard <xpoinsard@free.fr>
2006-04-13 15:46 Re: Date format problem with INSERT statement. Guy Rouillier <guyr@masergy.com>
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