views:

31

answers:

1

I have a table in an Openoffice Database, containing two date columns. I'm trying to create a view that will aggregate all the rows in these columns and sum up the difference between these two columns in minutes.

This is pretty trivial, and in Postgres it would look like:

SELECT SUM(EndDate-BeginDate) AS total_minutes FROM mytable

What is the equivalent syntax in HSQLDB? I can't find much documentation on their date functions, and all the "standard" methods I'm familiar with return a syntax error.

+1  A: 

It's a similar syntax in HSQLDB 2.0

SELECT SUM((EndDate-BeginDate) MINUTE) AS total_minutes FROM mytable

In HSQLDB 1.8.x used in OpenOffice, try the DATEDIFF() function as documented in the HSQLDB Guide

fredt
Thanks. Does HSQL support combining date and time types for doing a similar comparison on datetime types?
Chris S
HSQLDB supports DATE, TIME, and TIMESTAMP. Values of each type can be compared to each other. DATE values can be converted to TIMESTAMP for comparison. In 2.0 there is a function to combine a DATE and a TIME value to form a TIMESTAMP. There is extensive coverage of date / time functions in the 2.0 docs. BTW, you can use version 2.0 as an external database with OOo.
fredt