efmarshall / h2database

Automatically exported from code.google.com/p/h2database
0 stars 0 forks source link

trunc(timestamp) could return invalid value. #468

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.run this query at afternoon.
  select trunc(current timestamp) ;

sql> select trunc(current timestamp);
TRUNC(CURRENT_TIMESTAMP())
2013-05-26 12:00:00.0

What is the expected output? What do you see instead?

should return '2013-05-26 00:00:00.0'.

Please use labels and text to provide additional information.

org.h2.expression.Function: around line 1018

        case TRUNCATE: {
            if (v0.getType() == Value.TIMESTAMP) {
                java.sql.Timestamp d = v0.getTimestamp();
                Calendar c = Calendar.getInstance();
                c.setTime(d);
                c.set(Calendar.HOUR, 0);
                c.set(Calendar.MINUTE, 0);
                c.set(Calendar.SECOND, 0);
                c.set(Calendar.MILLISECOND, 0);

It is only necessary to add 'c.set(Calendar.AM_PM, 0)'.

Original issue reported on code.google.com by litail...@gmail.com on 26 May 2013 at 1:36

GoogleCodeExporter commented 9 years ago
Thanks! I will fix it.

Original comment by thomas.t...@gmail.com on 27 May 2013 at 8:07

GoogleCodeExporter commented 9 years ago
Should be fixed in version 1.3.173

Original comment by thomas.t...@gmail.com on 28 Jul 2013 at 2:53