I have a database query that truncates milliseconds off database timestamp 
values using the following logic:

DATEADD(second, DATEDIFF(second, '2000-01-01', zas.tstamp), '2000-01-01')

This has been failing since Britain switched to daylight savings time at 
the weekend. In the expression, the date '2000-01-01' is just an arbitrary 
value. The expression calculates the difference between that date and the 
database column of interest, but only to seconds precision, then creates a 
new date by adding this difference back to the same arbitrary value. This 
should have the affect of truncating the milliseconds. I chose this because 
it is recommended on stack overflow as a reasonably portable way of writing 
this logic.

However, on H2, running this now (in daylight savings time) has the affect 
of adding an hour to the time! i.e. if I run

DATEADD(second, DATEDIFF(second, '2000-01-01', '2016-03-31'), '2000-01-01')

you would expect to get back

2016-03-31 00:00:00

but in fact you get back

2016-03-31 01:00:00

By contrast, it runs as expected on SQL server.

This looks like a bug to me?

Hedley


-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/d/optout.

Reply via email to