29

I need something like

select * from tableName where date_column > now()

However, now() doesn't work in H2. Please advise.

yglodt
  • 13,807
  • 14
  • 91
  • 127
Pavel Vyazankin
  • 1,470
  • 6
  • 18
  • 27

2 Answers2

45

use CURRENT_TIMESTAMP

select * from tableName where date_column > CURRENT_TIMESTAMP()
John Woo
  • 258,903
  • 69
  • 498
  • 492
  • In h2 my select now() doesn't work but in update tbl set col = now() it works. How does this fit together? Also they list now() as alternative to current_timestamp on http://www.h2database.com/html/functions.html#current_timestamp – tObi May 19 '17 at 16:10
  • @john-woo what if date_column is of type date, not timestamp? I'm getting `ORA-30088: datetime/interval precision is out of range` in Oracle for `CURRENT_TIMESTAMP() - date_column` – mdziob Dec 09 '19 at 20:56
16

IF you want to compare with present date only then use

select * from tableName where date_column > CURRENT_DATE()

IF you want to compare with present date and time also

select * from tableName where date_column > CURRENT_TIMESTAMP