this query will retrieve all records during last 7 days.
SELECT * FROM STATISTICS WHERE TIMESTAMP > DATEADD('DAY',-7, NOW())
How can I change the query to include the records from midnight 7 days ago?
ex.
SELECT DATEADD('DAY',-7, NOW())
Gives: 2013-09-25 13:46:54.372
But I would like to have: 2013-09-25 00:00:00.000
Mainly, H2 database can be configured to run as inmemory database, which means that data will not persist on the disk. Because of embedded database it is not used for production development, but mostly used for development and testing.
H2 is an SQL database engine that is written in Java™ that implements the JDBC API. A browser-based console application is included. The H2 database is preinstalled with the Cúram software. After you install the Cúram platform software, the self-contained database is located in the %CURAMSDEJ%\drivers\h2. jar file.
Stored procedure in H2 database is same as java methods.So write java methods and can invoke using aliases.
For anyone interested, here is a solution.
Using CURRENT_DATE instead of NOW() does the trick!
ex:
SELECT * FROM STATISTICS WHERE TIMESTAMP > DATEADD('DAY',-7, CURRENT_DATE)
http://www.h2database.com/html/functions.html#dateadd
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With