db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rick Hillegas <rick.hille...@oracle.com>
Subject Re: Milisecond support?
Date Thu, 05 Apr 2012 14:28:43 GMT
Hi Libor,

The reference manual needs to be corrected. Derby supports 9 nanosecond 
digits. See the following script output:

ij> connect 'jdbc:derby:memory:db;create=true';
ij> create table t( a timestamp );
0 rows inserted/updated/deleted
ij> insert into t( a ) values ( timestamp( '2012-04-05 07:16:19.123' ) );
1 row inserted/updated/deleted
ij> insert into t( a ) values ( timestamp( '2012-04-05 07:16:19.123456' ) );
1 row inserted/updated/deleted
ij> insert into t( a ) values ( timestamp( '2012-04-05 
07:16:19.123456789' ) );
1 row inserted/updated/deleted
ij> select * from t;
A
-----------------------------
2012-04-05 07:16:19.123
2012-04-05 07:16:19.123456
2012-04-05 07:16:19.123456789

3 rows selected

Hope this helps,
-Rick

On 4/5/12 6:16 AM, Libor Jelinek wrote:
> Hello all,
> does Derby TIMESTAMP data type support millisecond? In reference 
> manual (http://db.apache.org/derby/docs/10.8/ref/rrefsqlj27620.html) 
> is stated:
> /yyy-mm-dd hh:mm:ss[.nnnnnn]
> yyyy-mm-dd-hh.mm.ss[.nnnnnn]/
> /The first of the two formats above is the java.sql.Timestamp format./
>
> /The year must always have four digits. Months, days, and hours may 
> have one or two digits. Minutes and seconds must have two digits. 
> *Nanoseconds, if present, may have between one and six digits.*/
>
> However because 1 millisecond = 1 000 000 nanoseconds even 1 
> millisecond can't be stored because it has 7 digis (max is 6)...
>
> Also, IMHO because 1 second = 1 000 000 000 nanoseconds, so nanosecond 
> part should have 9 digits, not 6. Also, 
> http://docs.oracle.com/javase/7/docs/api/java/sql/Timestamp.html#setNanos(int) 
> <http://docs.oracle.com/javase/7/docs/api/java/sql/Timestamp.html#setNanos%28int%29>

> expect that nano part will have max 9 digits.
>
> Thanks for your comments.
>
> --
> Hezky den / Have a nice day
> Libor JEL├ŹNEK
>
> VIRTAGE SOFTWARE // software - design - web
> Lucni 542 // 285 04 Uhlirske Janovice // Czech Republic
> support: +420 315 555 488 // cell: +420 777 205 142
> email/jabber: ljelinek@virtage.com <mailto:ljelinek@virtage.com> // 
> web: www.virtage.com <http://www.virtage.com>
>
> Visit our developer adventures at http://devblog.virtage.com!
>


Mime
View raw message