H2 - DATEADD for complete day

14,152

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

Share:
14,152
user955732
Author by

user955732

Updated on June 19, 2022

Comments

  • user955732
    user955732 about 2 years

    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

  • Enrico Giurin
    Enrico Giurin over 6 years
    I used this: DATEADD('DAY',-10, CURRENT_DATE()